SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 IF ELSE in SELECT STATEMENT
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 04/17/2006 :  10:48:38  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
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

USA
15688 Posts

Posted - 04/17/2006 :  10:49:21  Show Profile  Visit robvolk's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000