|Table of contents|
SQL Theorys: Using the SELECT statement to summarise data
A very useful feature of SQL is the ability to summarise data. This allows you to answer questions such as
- List all the areas people live in?
- How many Males and Females are there in a set of data?
- How many people live in a certain area?
- What is the total amount spent in different regions?
To Answer the questions we can modify the SELECT statement using
- DISTINCT (To list remove any duplicate rows)
- COUNT, AVG to do mathematical calculations such as add up values, find the average
- GROUP plus COUNT to add up something within each group
Your task on this page is to
To find out Where your clients come from.
To find out how many clients you have.
To find out how many doctors you have as clients.
How many clients you have For each Salute type (e.g. Mrs, Mr,Ms,Dr).
How many transactions happened in a each year.
Some statistics for account transactions.
This is just a start, to find out more refer to DuBois (2009, p75-84).
- DuBois, P. (2009) MySQL. Developer's Library. Fourth Ed. Pearson