


Where I write a query I have a choice about the data returned

A) I can get detailed data, 1 record per row of the database

B) I can get summary data, 1 record per SET of rows in the database


for example

select *
from world.city  <- will return detailed data (choice A) and I will get 4000+
                     records in the results
                     
or

select count(*)
from world.city <- I will get a single results (choice B) which is the SUMMARY data
                      for the set of rows I am accessing
                      
WARNING: You CANNOT ask for both detailed and summary data on the same query

this will NO run:

select count(*), name
from world.city


SQL support these summary functions (function use parentheses)

SUM()
AVG()
MIN()
MAX()
COUNT()

select max(total_amount), min(total_amount), 
  avg(total_amount), count(*), sum(total_amount),
  count(distinct customer_id)
from customer.orders



Null values are IGNORED in these summry function
for example:

select count(*), count(district)
from world.city

I get 4082 cities, but only 4079 districts, because some of the city have a null district

