Home | Site map   
Home Products Downloads Support Contacts
   
  Interactive SQL Tutorial
 

9. Miscellaneous SQL statements. Aggregate Functions.
I will discuss five important aggregate functions: SUM, AVG, MAX, MIN, and COUNT. They are called aggregate functions because they summarize the results of a query, rather than listing all of the rows.

SUM () gives the total of all the rows, satisfying any conditions, of the given column, where the given column is numeric.
AVG () gives the average of the given column.
MAX () gives the largest figure in the given column.
MIN () gives the smallest figure in the given column.
COUNT(*) gives the number of rows satisfying the conditions.

Looking at the tables at the top of the document, let's look at three examples:
SELECT SUM(SALARY), AVG(SALARY)
FROM EMPLOYEESTATISTICSTABLE
This query shows the total of all salaries in the table, and the average salary of all of the entries in the table.
SELECT MIN(BENEFITS)
FROM EMPLOYEESTATISTICSTABLE
WHERE POSITION = 'Manager'
This query gives the smallest figure of the Benefits column, of the employees who are Managers, which is 12500.
SELECT COUNT(*)
FROM EMPLOYEESTATISTICSTABLE
WHERE POSITION = 'Staff'
This query tells you how many employees have Staff status (3).

Index   << Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 Next >>


If you like to see how it works enter SQL statement and press Execute

 
 

Home | Products | Downloads | Support | Contacts

Customer quotes

Once again I want to tell you how impressive your software is. I am a computer applications teacher in the school so I don't know how much praise from me means to you. All I can tell you is that it is wonderful to find software that is easy to use and works so well.

Ian Roller
Ireland

What I needed to do was build a members log in area for a web site that the user could update as new people joined. He wanted this done in two days. With not much time I downloaded this software and had the lot done in under 3 min. Normal time for this would be about 5 days and even then you would still be debuging your scripts.



Richard Murray
Web developer

Contact us:

Xlinesoft.com
Herndon, VA 20171, USA

  1-888-290-6617
  support@xlinesoft.com

  © 1999 - 2005 XLineSoft. All rights reserved. All comments send to webmaster@xlinesoft.com