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

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -