1.

What is the purpose of group by command? How is it different from Order by command? Give example.

Answer»

The GROUP BY statement is used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or more columns.

The ORDER BY keyword is used to sort the result-set in ascending or descending order Example of Group By 

SELECT Dept No, COUNT(*) AS No of Teachers

FROM Teacher

GROUP BY Dept No;

Example of Order By

SELECT First Name, Last Name

FROM Teacher

ORDER BY First Name;



Discussion

No Comment Found

Related InterviewSolutions