Practical - 5
Practical - 5
Practical No : 5
Aim : 1. Group by
2. Having
Group by clause: Group by clause is used to group a selected set of rows into a
set of summary rows by the values of one or more columns. It is always used in
conjunction with one or more aggregate function. This optional clause tells
Oracle/SQL Server to group rows based on distinct values that exists for specified
columns.
Select <columnname 1><columnname 2>...<columnname n>,
Aggregate_function(<expression>) from tablename Where <condition>
Group by <columnname 1><columnname 2>...<columnname n>;
WHERE is used to filter rows before grouping and HAVING is used to exclude records
after grouping
Write SQL to answer following questions: