/* A select with all clauses */ SELECT vendor, SUM(amount) paid, COUNT(amount) tally FROM payment /* the FROM clause */ WHERE amount > 100 /* the WHERE clause */ GROUP BY vendor /* the GROUP BY clause */ HAVING SUM(amount) > 150 /* the HAVING clause */ ORDER BY 2, 3 DESC /* the ORDER BY clause */