Sunday, January 9, 2011

Difference between ORDER BY clause and GROUP BY clause in sql server.


here is the most comman difference of the order by clause or group by clause.
==>  the order by clause display the data in the sorted order of the given field

ex:- select * from employee order by emp_name desc,emp_no asc;

this query gives the output  in the ascending oredr of the emp_no and descending order of the emp_name.

==> while the group by clause is use to display the data in group of given field.

ex;- select * from employee group by emp_name.

this give the output data in the group of the emp_name.

No comments:

Post a Comment