General information
Forum:
Microsoft SQL Server
Title:
If condition inside SQL command
Environment versions
SQL Server:
SQL Server 2005
Dear Expert,
Is it possible to have IF condition inside SQL command at Ms.SQL (pls see below)? ..
please help..
Many thanks in advance
Regards
Winanjaya
SELECT CA_ACODE.*, CA_ACODE.ATYPE, CA_HOST.HOSTCODE, CA_HOST.HOSTNAME AS CA_HOST_HOSTNAME, CA_HOST.EMAIL AS CA_HOST_EMAIL, IF (CA_ACODE.ATYPE = 1, 'Local', IF (CA_ACODE.ATYPE = 2, 'Long Distance', IF (CA_ACODE.ATYPE = 3, 'International', IF (CA_ACODE.ATYPE = 4, 'Others', '')))) AS ATYPENAME
FROM CA_ACODE LEFT OUTER JOIN CA_HOST ON CA_ACODE.HOSTCODE = CA_HOST.HOSTCODE
ORDER BY CA_ACODE.HOSTCODE, CA_ACODE.ATYPE, CA_ACODE.AGROUP, CA_ACODE.ZN, CA_ACODE.ACODE
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only