group by clause ; visual representation

f:id:mat5ukawa:20150504223513j:plain

If use 'group by', set will be divided to subgroups.

implements

CREATE TABLE membeers (
  name text,
  age integer,
  home text
);

-- abbreviated insertion...

SELECT * FROM members;

  name   | age |  home   
---------+-----+---------
 shimano |  25 | tottori
 kitano  |  32 | tottori
 hattori |  22 | osaka
 sugino  |  23 | hyogo
 mishima |  28 | hyogo
 hirano  |  28 | osaka
 sato    |  33 | tottori

SELECT home, TRUNC(AVG(age), 1) as age_avg
  FROM members
  GROUP BY (home);

  home   | age_avg 
---------+---------
 osaka   |    25.0
 tottori |    30.0
 hyogo   |    25.5

reference

thanks for your lecture.

www.youtube.com