0

Use of group by?

please explain

26th Jan 2017, 9:50 AM
Govind Pal
Govind Pal - avatar
3 Réponses
+ 1
The group by is used to collect tuples with recurring values and list them as a group. you can use the group by in conjunction with the count to find out how many elements are in a particular group. e.g SQL> SELECT NAME, SUM(SALARY) FROM CUSTOMERS GROUP BY NAME; +----+----------+-----+-----------+----------+ | ID | NAME | AGE | ADDRESS | SALARY | +----+----------+-----+-----------+----------+ | 1 | Ramesh | 32 | Ahmedabad | 2000.00 | | 2 | Ramesh | 25 | Delhli | 1500.00 | | 3 | kaushik | 23 | Kota | 2000.00 | | 4 | kaushik | 25 | Mumbai | 6500.00 | | 5 | Hardik | 27 | Bhopal | 8500.00 | | 6 | Komal | 22 | MP | 4500.00 | | 7 | Muffy | 24 | Indore | 1'0000.00 | +----+----------+-----+-----------l+----------+
26th Jan 2017, 10:13 AM
Clement Kunda
Clement Kunda - avatar
+ 1
Thank you...
26th Jan 2017, 12:55 PM
Govind Pal
Govind Pal - avatar
0
The SQL GROUP BY clause can be used in a SELECT statement to collect data across multiple records and group the results by one or more columns. Syntax SELECT column_name, aggregate_function(column_name) FROM table_name GROUP BY column_name; Example SELECT dept_id, SUM(salary) AS total_salaries FROM employees GROUP BY dept_id;
3rd Feb 2017, 1:24 PM
Akwin Lopez
Akwin Lopez - avatar