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.
| Author |
Topic |
|
Maverick_
Posting Yak Master
107 Posts |
Posted - 2010-11-04 : 08:08:09
|
Hi allI am trying to write a case statement to populate "Complete Date" for work done.I have three possible fields to select from.Estimate_DateActual_DateEffective_DateIf Actual_Date is populated, use that as Complete Date NEXTIf Actual_Date is not populated, use Estimate_Date NEXTIf neither of these two are populated then use Effective_DateAnyone know how I could do write this?  |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-11-04 : 08:12:34
|
| coalesce(Estimate_Date,Actual_Date,Effective_Date) as NEXT_dateMadhivananFailing to plan is Planning to fail |
 |
|
|
Maverick_
Posting Yak Master
107 Posts |
Posted - 2010-11-04 : 12:00:34
|
| Thank you MadhivaanUnfortunately coalesce is not allowed so I can only use CASE statement, is there a way of doing this with CASE? :) |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-11-04 : 12:12:15
|
quote: Originally posted by Maverick_ Thank you MadhivaanUnfortunately coalesce is not allowed so I can only use CASE statement, is there a way of doing this with CASE? :)
Why, is this homework? If not investigate nested case statements. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-11-08 : 04:33:37
|
quote: Originally posted by Maverick_ Thank you MadhivaanUnfortunately coalesce is not allowed so I can only use CASE statement, is there a way of doing this with CASE? :)
Are you using SQL Server? Coalesce is supported in many RDBMSsMadhivananFailing to plan is Planning to fail |
 |
|
|
Maverick_
Posting Yak Master
107 Posts |
Posted - 2010-11-08 : 06:08:08
|
| Hi all,Thank you for your help. The client does not like using COALESCE statement so in the end I managed to get case statement working. |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-11-08 : 06:17:38
|
quote: Originally posted by Maverick_ Hi all, The client does not like using COALESCE statement...
Now thats amazing.Imagine a client who does not like a 'select' stament. PBUH |
 |
|
|
|
|
|