sql - Subquery returned more than 1 value. VB6 -
hi i'm trying select value of movementline.qty
if movements.movementscode
equal rw if not put 0.00
select levelfield1.description, products.reportuom, products.productcode, products.description, isnull(sum(receivingline.qty), 0.00) [b.delivery], movements.movementcode, isnull((select qty movementline movementcode = 'rw'), 0.00) [b. returned] products left join levelfield1 on levelfield1.levelfield1code = products.levelfield1code left join receivingline on receivingline.productcode = products.productcode left join movementline on movementline.productcode = products.productcode left join movements on movements.movementid = movementline.movementid group levelfield1.description, products.reportuom, products.productcode, products.description, movementline.qty, movements.movementcode
i got error
subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression. warning: null value eliminated aggregate or other set operation.
your code make think deeply. because there maybe join problem , may not correct result. problem solve using top 1 correct result not possible. here need use case. hope problem solve using bellow code.
select levelfield1.description, products.reportuom, products.productcode, products.description ,isnull(sum(receivingline.qty),0.00) [b.delivery], movements.movementcode, case when movementline.movementcode = 'rw' isnull(movementline.qty,0.00) esle 0.00 end [returned] products left join levelfield1 on levelfield1.levelfield1code = products.levelfield1code left join receivingline on receivingline.productcode = products.productcode left join movementline on movementline.productcode = products.productcode left join movements on movements.movementid = movementline.movementid group levelfield1.description, products.reportuom, products.productcode, products.description, movementline.qty,movements.movementcode
Comments
Post a Comment