Re: devide and summarize sql result (all)

From: Beena Emerson <memissemerson(at)gmail(dot)com>
To: Janek Sendrowski <janek12(at)web(dot)de>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: devide and summarize sql result (all)
Date: 2013-08-16 03:48:34
Message-ID: CAOG9ApEsxV4RrS9Z2DbTp7v-=eisuimmo6cZ_-on84CJTHKpVA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Janek,

You can try:

=# SELECT name, perc/5*5 || '-' || perc/5*5+5 AS range, count(*) as matches
FROM test GROUP BY name, perc/5 ORDER BY perc/5;
name | range | matches
-------+--------+---------
franz | 75-80 | 1
jason | 75-80 | 1
franz | 80-85 | 1
smith | 85-90 | 2
smith | 95-100 | 2
(5 rows)

--
Beena Emerson

In response to

Browse pgsql-general by date

  From Date Subject
Next Message S H 2013-08-16 05:45:49 Re: Commit problem in read-commited isolation level
Previous Message Robert James 2013-08-15 22:40:59 Forcing materialize in the planner