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 |
|
theboyholty
Posting Yak Master
226 Posts |
Posted - 2010-02-19 : 09:11:51
|
| Is there a function to return the smaller of 2 arguments? i.e. 2 dates. I know i could use datediff but that seems messy.Thanks.---------------------------------------------------------------------------------http://www.mannyroadend.co.uk The official unofficial website of Bury Football Club |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-02-19 : 09:18:50
|
| select case when date1<date2 then date1 else date2 end from your_tableMadhivananFailing to plan is Planning to fail |
 |
|
|
theboyholty
Posting Yak Master
226 Posts |
Posted - 2010-02-19 : 09:20:48
|
| Hmm yep i did that end the end, I just wondered if there was a function along the lines of coalesce.thanks.---------------------------------------------------------------------------------http://www.mannyroadend.co.uk The official unofficial website of Bury Football Club |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-19 : 09:25:29
|
you could do this alsoSELECT pk,MIN(dateval)FROM(SELECT date1 AS dateval,pk FROM tableUNION ALLSELECT date2,pk FROM table)tGROUP BY pk ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-02-19 : 10:15:20
|
quote: Originally posted by theboyholty Hmm yep i did that end the end, I just wondered if there was a function along the lines of coalesce.thanks.---------------------------------------------------------------------------------http://www.mannyroadend.co.uk The official unofficial website of Bury Football Club
In ORACLE there is a function called least which does what you want. In SQL Server there is no such functionMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|