The GROUP BY() Function is used to conjunction with an aggregate function to group the result-set by one or more column.
The basic syntax is as follows:
| 
SELECT column_name,Aggregate_Function(column_name) FROM table_name WHEREcolumn_name operator value GROUP BY column_name | 
| Employee | ||||
| Emp_id | Name | Surname | Salary | Dept_id | 
| 1 | Rajesh | Khanna | 45000 | 2 | 
| 2 | Sneha | Gupta | 55000 | 4 | 
| 3 | Sandeep | Nehte | 95000 | 1 | 
| 4 | Kirti | Patil | 25000 | 3 | 
| 5 | Nilesh | Jadhav | 45000 | 3 | 
| 6 | Dipesh | Das | 35000 | 5 | 
| 7 | Kailash | Rane | 62000 | 1 | 
| 8 | Kavita | Deshpande | 48000 | 3 | 
| 9 | Sanjay | Datt | 50000 | 3 | 
| 10 | Shruti | Hasan | 78000 | 1 | 
Syntax For SQL:
| 
SELECT Name, SUM(salary) FROM employee GROUP BY Dept_id | 
After Execute: 
| First(Salary) | 
| 53800.00 | 
 
 
 
 
 
   
No comments:
Post a Comment