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 |
tran008
Starting Member
38 Posts |
Posted - 2007-08-01 : 09:39:30
|
I need to sort the order base on the following: col1, col2,col3. Col1 is group together, col2 is base on the value of col3. eg:col1 col2 col310685 784 033884 706 10629018 290 94033884 106 033884 191 70629018 194 29010686 217 80010685 801 78429018 940 010686 783 010685 218 80110686 800 783 col1 col2 col333884 191 70633884 706 10633884 106 029018 194 29029018 290 94029018 940 010685 218 80110685 801 78410685 784 010686 217 80010686 800 78310686 783 0 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-01 : 09:41:15
|
ORDER BY Col1, Col3 DESC, Col2 E 12°55'05.25"N 56°04'39.16" |
 |
|
tran008
Starting Member
38 Posts |
Posted - 2007-08-01 : 09:55:17
|
Peso,thank for the quick response, but result not in order: Your suggestion will product:col1 col2 col329018 290 94029018 194 29029018 940 0which should be:29018 194 29029018 290 94029018 940 0 |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-01 : 09:59:31
|
Yikes!ORDER BY Col1, Col2, Col3If this is not OK, then you have to explain your business rules, because you are not consistent in your provided expected output. E 12°55'05.25"N 56°04'39.16" |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-01 : 10:02:26
|
Or thisORDER BY Col1, CASE WHEN Col3 = 0 THEN 1 ELSE 0 END, Col2 E 12°55'05.25"N 56°04'39.16" |
 |
|
tran008
Starting Member
38 Posts |
Posted - 2007-08-01 : 10:09:34
|
Thanks Peso, ORDER BY Col1, CASE WHEN Col3 = 0 THEN 1 ELSE 0 END, Col2did the jobs. |
 |
|
|
|
|
|
|