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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 IF ELSE in SELECT STATEMENT

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-04-17 : 10:48:38
nmar writes "Dear Sirs,

I would like to use IF instead of CASE in SELECT Statement.

example :

SELECT FIELD11, FIELD12,
CASE WHEN FIELD13 > (SELECT SUM(FIELD23)
FROM TBL2
WHERE TBL1.FIELD11 = FIELD21
)
THEN
(SELECT SUM FIELD24)
FROM TBL2
WHERE TBL1.FIELD11 = FIELD21
)
ELSE
'NO VALUE'
END
AS 'MYCOLUMN'
FROM TBL1 TBL1

Please, how I can use IF instead of CASE (with CASE works fine.)"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-04-17 : 10:49:21
If CASE works fine, then why would you want to use IF? Not that it matters, IF cannot be used this way in T-SQL.
Go to Top of Page
   

- Advertisement -