The Group by Clause

Domain Hosting image
Web Hosting
Dedicated server
ssl certificate
Web Design image
Email

The GROUP BY clause groups the selected rows based on the value of expression for each row and returns a single row summary information for each group. Suppose you want to know the average salary of the employees in each department; you can use SQL function AVG() to list the average salary in each department, enter:

SQL > SELECT DEPTNO, AVG(PAY)

2 FROM EMP

3 GROUP BY DEPTNO;

Other aggregate functions that can be used along with GROUP BY clause are:

<b>COUNT()</b>

sum 0 MAX 0 MIN 0 2.2.9.1 Count() The count function counts the number of non null number values, distinct number values, or rows selected by the query. For example, if you wish to know the number of employees listed by their employee numbers in the EMP table, then enter:
<b>Sum()</b>

The SUM function is used to find the sum or total of the selected values. If you want to know the sum or salaries paid for various job in an organisation, then enter:

SQL > SELECT JOB, SUM(PAY) FROM EMP

2 GROUP BY JOB;



Domain Name Search

www.


Copyright (C) 2007. Web Domain design hosting. All rights reserved.