On 01/14/2012 09:22 PM, plasmasoftware net wrote:
hello ...I don't understand, Wouldn't have been: PCA 0 KRT 2 PAK 20 PCS MOUSE 0 KRT 2 PAK 25 PCS ? anyways, if the "units" table was something like this : unit convUnit ratio PCS PCS 1 PCS KRT 1/120 PCS PAK 1/10 (foreseeing other types of conversions) One simple solution is: SELECT s.name, (select s.qty * ratio FROM unit WHERE unit='PCS' and conv='KRT'), ' KRT ', (select s.qty * ratio FROM unit WHERE unit='PCS' and conv='PAK'), ' PAK ', s.qty, ' PCS' FROM stock s; rounding or truncating is up to you. |