Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Binning data
On Mon, 26 Apr 1999 16:24:18 GMT, tkyte_at_us.oracle.com (Thomas Kyte)
wrote:
>>I have a series of real numbers, and I want to bin the data by ranges,
>>and get a count of the number of values in each bin. The values range
>>from 75.1 to 1200.4, and I want to bin them in steps of fifty. Thus, I
>>want to count all values between 50.0001 and 100.0000, between
>>100.0001 and 150.0000, etc., all the way up to the range from
>>1200.0001 to 1250.0000.
>>
>
>select trunc( column/50 ), count(*) from T group by trunc(column/50)
>/
>
>so, 0 .. upto but not including 50 -> 0
> 50 .. upto but not including 100 -> 1
> and so on...
>
Thanks very much Tom. Does just what I need. Thanks also to Mauro Papandrea who suggested using floor instead of trunc.
James Petts Received on Wed Apr 28 1999 - 03:12:29 CDT
![]() |
![]() |