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 |
shakthiA
Starting Member
12 Posts |
Posted - 2009-02-25 : 06:50:30
|
Hi I have a stored procedure that returns all the docs uploaded ordered by creation date. Now i want to change it like show a document with the id "1234" as always on top and the remaining results as today after to that document.For example: Today we have stored procedure that returns the result as:Id Title CreationDate Lang1pqr About obama 24/02/2009 enxyz You and Me 10/01/2009 abc KnowHow 01/12/2008 de12345 Yes And No 29/10/2008 deNow I want the result like:Id Title CreationDate Langxyz You and Me 10/01/2009 1pqr About obama 24/02/2009 enabc KnowHow 01/12/2008 de12345 Yes And No 29/10/2008 de Does anyone have any one idea.Any Help please......!Thanks in advance |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-02-25 : 08:43:52
|
How come there are 5 records in the wanted result, but only 4 in the provided sample data? E 12°55'05.63"N 56°04'39.26" |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-02-25 : 08:44:54
|
ORDER BY CASE WHEN ID = 'xyz' THEN 0 ELSE 1 END, CreationDate DESC E 12°55'05.63"N 56°04'39.26" |
 |
|
shakthiA
Starting Member
12 Posts |
Posted - 2009-02-25 : 08:50:43
|
Hi Peso, thanks for the reply. It worked. but can you explain it a little bit.Thanks alot!!quote: Originally posted by Peso ORDER BY CASE WHEN ID = 'xyz' THEN 0 ELSE 1 END, CreationDate DESC E 12°55'05.63"N 56°04'39.26"
|
 |
|
|
|
|