2 Aug 2013

Database Order by

DB related:


Order by:


1.The arguments for order by may not have to be in the select list can be in the sub queries of the select list.

2.Order by A,B,C : ordering of B will be done after ordering of A if the order of A is not disturbed, similarly to ordering of C also.

EX:In the below arrangement,

ABC
12000-1004000
-150002006000
15250-3005000

if I say "Order by A desc, B asc , c desc" in the query then the output will be
A               B               C
15200    -300        5000
12000    -100        4000
-15000    200        6000

if you see B column is not ordering in asc because if it orders in ascending then order of A will be disturbed, similarly for C also.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.