Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Filter out case statement

Author  Topic 

SQLSoaker
Posting Yak Master

169 Posts

Posted - 2010-03-31 : 15:41:17
Hello,

I have (in short)


SELECT ... , CASE WHEN SALESLINE.QTYORDERED = INVENTSUM.PICKED AND SALESTABLE.DOCUMENTSTATUS = 4 THEN 'VOID' ELSE '' END AS PICKEDVOID

FROM ...

WHERE PICKEDVOID <> 'VOID'


I get an error, invalid column name. I basically want to eliminate the 'VOID' in my select clause from my return data set...

Bad practice?

SQLSoaker
Posting Yak Master

169 Posts

Posted - 2010-03-31 : 16:15:36
to elaborate, I get an invalid column name of 'PICKEDVOID'...

Should I attempt to embed my case statement within the where clause?

Thanks in advance!
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2010-03-31 : 16:30:56
whats the use of CASE statement here?

...WHERE NOT (SALESLINE.QTYORDERED = INVENTSUM.PICKED AND SALESTABLE.DOCUMENTSTATUS = 4)
Go to Top of Page

SQLSoaker
Posting Yak Master

169 Posts

Posted - 2010-03-31 : 16:34:36
Thank you rohitkumar! Been a long day! :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-01 : 05:13:52
or use it like:-


select columns...
from
(
SELECT ... , CASE WHEN SALESLINE.QTYORDERED = INVENTSUM.PICKED AND SALESTABLE.DOCUMENTSTATUS = 4 THEN 'VOID' ELSE '' END AS PICKEDVOID

FROM ...
)t
WHERE PICKEDVOID <> 'VOID'




------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -