Search Postgresql Archives

Re: devide and summarize sql result (all)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux