sql server - SQL returning 'Subquery returned more than 1 value' error -
okay bit of code thats giving me error:
select orderid, requireddate, ( select datediff(dd,requireddate,shippeddate) sales.orders shippeddate > requireddate ) 'dayslate' sales.orders
and "subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression." error.
i'm not quite sure how fix it, when click on error message highlights select orderid, requireddate
bit.
is there wrong i'm not catching?
try below sql
select orderid, requireddate , case when shippeddate > requireddate datediff(dd,requireddate,shippeddate) else 0 end 'dayslate' sales.orders
the case..when statement can replace subquery
Comments
Post a Comment