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
 case when in where clause

Author  Topic 

shemayb
Posting Yak Master

159 Posts

Posted - 2007-06-13 : 02:07:11
is this correct?(where clause only)

where budget = case when price > 2.0 then 'True' else 'False' end

Funnyfrog

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-06-13 : 02:22:30
yes, if the budget stores the string information.

--------------------------------------------------
S.Ahamed
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2007-06-13 : 02:42:57
How about storing a date? is this the right way?

where TransferDate=Case when TransferDate > EndDate then EndDate else TransferDate end

Funnyfrog
Go to Top of Page

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-06-13 : 03:11:39
Post some sample data and required output you want.

--------------------------------------------------
S.Ahamed
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2007-06-13 : 03:30:15
for example: Transferdate is (YYYY-MM-DD format)2006-10-01 and enddate is 2006-09-12. if transferdate is > enddate,transferdate should be equal to endate.

Funnyfrog
Go to Top of Page

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-06-13 : 03:46:15
You can use it...Always try it then only u can see the difference....

--------------------------------------------------
S.Ahamed
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2007-06-13 : 03:49:50
thank you..

Funnyfrog
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-13 : 08:31:00
Also read about CASE expression in sql server help file for more informations

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -