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
 IF syntax question

Author  Topic 

tmaiden
Yak Posting Veteran

86 Posts

Posted - 2006-12-08 : 12:55:35
I am trying to get this little bit of sql to work and I am having the worst trouble.


SELECT CALLTYPE = CASE WHEN ({CD.CALL_TYPE}=3) then "OUTGOING" else
when ({CD.APPLIC_NUM}=1) then "OUTGOING" else
when ({CD.DEST_TYPE}="A") then "INCOMING" else
when ({CD.ORIG_TYPE}="A") then "OUTGOING" else
"UNKNOWN" END
FROM tablename CD


any help would be greatly appriciated!

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-08 : 13:03:26
[code]SELECT CALLTYPE =
CASE
WHEN CD.CALL_TYPE = 3 then 'OUTGOING'
when CD.APPLIC_NUM=1 then 'OUTGOING'
when CD.DEST_TYPE='A' then 'INCOMING'
when CD.ORIG_TYPE='A' then 'OUTGOING'
else 'UNKNOWN'
END
FROM tablename CD[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-12-08 : 13:04:33
1. You should use single quotes for literals.
2. If these are meant to be column names {CD.APPLIC_NUM}, you should change them to CD.[APPLIC_NUM]

You didn't say what problem you are having, so I can't help you any more than that.

CODO ERGO SUM
Go to Top of Page
   

- Advertisement -