From: "Txugo" <[EMAIL PROTECTED]>
> 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
-----
150
160
(2 rows)
richardh=> select cm,count(id) from people, heights where height>=cm group
by cm;
cm | count
-----+-------
150 | 4
160 | 2
(2 rows)
HTH
- Richard Huxton
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster