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 |
|
zai
Starting Member
9 Posts |
Posted - 2010-06-07 : 09:36:18
|
| Hello all,Is there a way for a field to have a value of either 'yes' or 'no' depending on anonther field?Basically, I have a date field called 'DateDue'. If that date field is less than GetDate, I would like another field to be flagged as 'yes'. Or perhaps there is another way to do this that is better. Please let me know.Thank you all so much. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-07 : 10:01:28
|
| select columns,case when DateDue<getdate() then 'yes' else 'no' end as status from tableMadhivananFailing to plan is Planning to fail |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-06-07 : 11:35:45
|
| As Madhivanan showed, you can simple select the value with that logic. Another option is to make a computed column. |
 |
|
|
zai
Starting Member
9 Posts |
Posted - 2010-06-07 : 11:56:36
|
| You guys are fantastic. Thank you both. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-08 : 02:24:48
|
quote: Originally posted by zai You guys are fantastic. Thank you both.
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|