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 |
|
BendJoe
Posting Yak Master
128 Posts |
Posted - 2008-10-01 : 12:44:13
|
| I need to sort a result set first based on a two columns.eg;the two columns are date and month. if I set order by month desc.I have hundreds of records for the same month.So I need to sort by date after words.How can I do this.I have Select Date,Month from Tableorder by month desc.I dont know how to add the second column sortingPlease help |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-10-01 : 12:51:08
|
| Select Date,Month from Tableorder by month desc,date descYou can specify many columns in order by clause with comma separated |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-01 : 12:51:35
|
| [code]Select Date,Month from Tableorder by month desc,date desc[/code] |
 |
|
|
BendJoe
Posting Yak Master
128 Posts |
Posted - 2008-10-01 : 12:52:58
|
| Thanks,One more question If I have a result set for a query is there a way to make it return the result set in random order each time the query is run.Thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-01 : 12:55:11
|
quote: Originally posted by BendJoe Thanks,One more question If I have a result set for a query is there a way to make it return the result set in random order each time the query is run.Thanks
yup you can useselect fields... from table1join table2.....order by NEWID() |
 |
|
|
BendJoe
Posting Yak Master
128 Posts |
Posted - 2008-10-01 : 13:03:00
|
| Thanks |
 |
|
|
|
|
|