Microsoft
Software
Hardware
Network
Question : TSQL CASE and the WHERE CLAUSE
Hi There,
I'm having difficulty trying to get my case statement in the where clause. This is what I am trying to do ..
Select bla bla
FROM bla bla
WHERE
case
when @Letter = 'TEST' then jn.PRINTED = 0 and jn.cust = 'ABC'
when @Letter = 'TEST1' then jn.PRINTED = 0 and jn.cust = 'XYZ'
else jn.PRINTED = 0 and jn.cust = 'XXX'
end
But I am getting a syntax error, can someone help with where I'm going wrong please?
TIA, Roger
Answer : TSQL CASE and the WHERE CLAUSE
Select blabla
FROM bla
WHERE
( @Letter = 'TEST' AND jn.PRINTED = 0 and jn.cust = 'ABC' )
OR
( @Letter = 'TEST1' AND jn.PRINTED = 0 and jn.cust = 'XYZ' )
OR (jn.PRINTED = 0 and jn.cust = 'XXX' )
Random Solutions
Report with two different records on same line
IIS 7 Enable Details Error messages remotely
VB.Net - BulkCopy Excel to SQL...works, but funky
SBS 2003 NT Backup SqlServerWriter Error 0x800423f4
Can't connect to SQL server 2008 (error 40 could not open a connection to the SQL Server)
Converting Access queries to T-SQL problems
LDAP/ Active Directory Password Unlock Error..
datagridview VS2008, bold a row
Can SQL query using multiple LIKE joins be improved
I can not find the record I added to table via search via query