pcplans.com § Help and Support How to: using SQL GROUP BY clause  

How to: using SQL GROUP BY clause

Article ID:7999
Last Review:Thursday, January 08, 2009
Revision:3.0

INTRODUCTION

How to: using SQL GROUP BY clause

symptomsIMPORTANT

How to: using SQL GROUP BY clause


IMPORTANT

How to: using SQL GROUP BY clause
The GROUP BY clause will gather all of the rows together that contain data in the specified column(s) and will allow aggregate functions to be performed on the one or more columns.
back to the top

How to: using SQL GROUP BY clause


SQL GROUP BY clause The GROUP BY clause will gather all of the rows together that contain data in the specified column(s) and will allow aggregate functions to be performed on the one or more columns. This can best be explained by an example: GROUP BY clause syntax:
SELECT column1, 


SUM(column2)
FROM "list-of-tables"
GROUP BY "column-list";


Let's say you would like to retrieve a list of the highest paid salaries in each dept:


SELECT max(salary), dept
FROM employee 
GROUP BY dept;


This statement will select the maximum salary for the people in each
unique department. Basically, the salary for the person who makes the
most in each department will be displayed. Their, salary and their
department will be returned.




  • NOTE: How to: using SQL GROUP BY clause
  • back to the top




    Last Reviewed:1/8/2009
    Keywords: kbHow kbhowtoHow kbHOWTOHow #7999 kbAudITProHow



        Contact

       ©1999-2008 Support at pcplans.com