Re: SQL - histogram
| От | Richard Huxton |
|---|---|
| Тема | Re: SQL - histogram |
| Дата | |
| Msg-id | 00cf01c109e8$be6a8880$1001a8c0@archonet.com обсуждение исходный текст |
| Ответ на | SQL - histogram (msalt@uol.com.br (Txugo)) |
| Список | pgsql-sql |
From: "Txugo" <msalt@uol.com.br> > I have a table where one record represent a person, including his height. > I'd like to know how many person have more than 150 cm, more than 160 cm > and so on. > How can I do that using SQL? > > Example: > people > 150 - 1000 > > 160 - 850 > > 170 - 500 > > 180 - 200 > > 190 - 30 > thanks in advance richardh=> select * from people;id | height ----+-------- 1 | 150 2 | 155 3 | 160 4 | 165 (4 rows) richardh=> select * from heights;cm -----150160 (2 rows) richardh=> select cm,count(id) from people, heights where height>=cm group by cm;cm | count -----+-------150 | 4160 | 2 (2 rows) HTH - Richard Huxton
В списке pgsql-sql по дате отправления: