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 |
somsahi
Starting Member
23 Posts |
Posted - 2011-10-16 : 00:30:00
|
hi,sorting two column by query like thisorder by employee,(date desc) ; desc is only on dateactual lit list isJohnson 20/1/2008JOHNSON 20/1/2007emmy 20/1/2009Emmy 20/1/2010reult isemmy 20/1/2009Emmy 20/1/2010JOHNSONS 20/1/2007Johnson 20/1/2008question1)why emmy came before Emmy and JOHNONS came befre johnson |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-16 : 00:33:45
|
the result posted is not for order by applied. as in result you've date sorted in ascending order and in order by you've specified descending. Emmy will come before Johnson as Emmy is alphabetically before Johnson..order by employee,date desc meansit first sorted by employeethen within each employee records it sorts them by descending order of date------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-16 : 00:35:29
|
yeah... if its case sensitive collation it will regard emmy and Emmy as different and also JOHNSON and johnson------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-16 : 00:40:29
|
this was the order i got when i used a case sensitive collationdeclare @table table(var varchar(100))insert into @tableselect 'test' union allselect 'Test' union allselect 'TEST' union allselect 'TEst' SELECT varFROM @tableORDER BY var COLLATE SQL_Latin1_General_CP1_CS_AS ASCoutput-----------------------------------------------------------------TESTTEstTesttest ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
paultech
Yak Posting Veteran
79 Posts |
|
jassi.singh
Posting Yak Master
122 Posts |
Posted - 2011-10-17 : 01:37:54
|
you can change the collation at the query level to get exact resultPlease mark answer as accepted if it helped you.Thanks,Jassi Singh |
|
|
|
|
|