Saturday, December 5, 2009

What is the difference between GROUP BY and ORDER BY in Sql?

ORDER BY [col1],[col2],…,[coln];
Tells DBMS according to what columns
it should sort the result. If two rows will have the same value in col1
it will try to sort them according to col2 and so on.
[col1],[col2],…,[coln]; Tells DBMS to group results with same value of
column col1. You can use COUNT(col1), SUM(col1), AVG(col1) with it, if
you want to count all items in group, sum all values or view average

No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off