Sql Histogram
Mar 20, 2008
Hi all -
I would like to know how in sql I can generate a histogram of data with a known range of values. Here is an example of what I would like to be able to generate.
I would like to see the count of how many values range from .0001 to .0002 and .0002 to .0003 and .0003 to .0004
up to .0019
Then I would like to see greater variation such as stepping every .005 instead of .0001 after .0019. So this would be .005 to .010, .010 to .015
VALUE
0.0001
0.0002
0.0001
0.0001
0.0001
0.0001
0.0006
0.0008
0.001
0.0012
0.0014
0.0016
0.0018
0.0017
0.0007
0.0019
0.002
0.005
0.006
INTERVAL FREQUENCY
------------------------- -------------------------
0 2762
0.0001 370
0.0002 338
0.0003 246
0.0004 175
0.0005 86
0.0006 41
0.0007 24
0.0008 12
0.0009 13
0.001 9
0.0011 10
0.0012 7
0.0013 5
0.0014 5
0.0015 4
0.0016 2
0.0017 1
0.0018 1
0.0019 2
0.005 26
0.01 8
0.015 5
0.02 3
0.025 0
0.03 1