DWP  Demo  Example×  

Aggregate Query


SELECT COUNT(letter_grade) FROM  grade
  WHERE letter_grade='A';    /* how many As */

SELECT COUNT(DISTINCT major) FROM
  student;     /* how many different majors */

SELECT AVG(hw2) as hw2_avg,
       MAX(hw2) as hw2_max,
       MIN(hw2) as hw2_min FROM grade;

SELECT SUM(amt) as sales FROM
  order;    /* total sales from order table */

SELECT GROUP_CONCAT(first_name, '_', last_name)
  AS name_list FROM student;

Download Code

Download Aggregate.sql.