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 |
pcride
Starting Member
9 Posts |
Posted - 2011-09-27 : 23:46:46
|
Hi, I have 2 date fields, need to compare themIf Date 1 >= Date 2, then 0, else 1The result needs to be a new column added to my data set |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-28 : 00:03:08
|
use case when select.....case when Date 1 >= Date 2 then 0 else 1 end as yournewcolumnname.... ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
pcride
Starting Member
9 Posts |
Posted - 2011-09-28 : 01:28:57
|
Thanks for the fast response.I did this and it gives meIncorrect syntax near the keyword casedoes it have to be after the From DataBasename or after the WHERE clause? |
|
|
pcride
Starting Member
9 Posts |
Posted - 2011-09-28 : 01:31:57
|
Never mind I got it.Thanks againIf you could provide addtional assistance.Now I need to divide that code with the total number of records in the same query result.Would it be Sum (Case when? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-28 : 01:40:25
|
whats meaning of that? can you tell me what you're trying to calculte?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|