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

View 3 Replies


ADVERTISEMENT

Drawing Histogram/chart

May 8, 2008

I have a following code to "draw" a "histogram" :-)


use tempdb
go

declare @temp table
(id int identity(1,1)
,valuess int)

insert into @temp (valuess) values (64)
insert into @temp (valuess) values (12)
insert into @temp (valuess) values (23)
insert into @temp (valuess) values (45)
insert into @temp (valuess) values (30)


select
id
,valuess
,histogram = cast(replicate('*', valuess*0.4) as nvarchar(50))
,length = len(cast(replicate('*', valuess*0.4) as nvarchar(50)))
from @temp

order by valuess desc


Is there any better way to do it; maybe even a function?

Thanks :)

View 2 Replies View Related

Creating Data For A Histogram.

Jul 23, 2005

I have a table, TableA with amongst other fields, a field for Qty.Qty can range from 0 to 100.How do I count the number of rows with a qty between 1 and 10, 11 and20, 21 and 30, and so on using one SQL statement? Regards,Ciarán

View 16 Replies View Related

DB Engine :: Histogram Of Wait Events

Oct 5, 2015

I would like to know what a particular session is waiting on (cpu, io, memory etc).

For that I try to figure out how to use extended events. I would prefer to avoid the use files written to db-server, why I tried "histogram target".

Well my attempt does not produce usefull output,

-- check current event sessions

SELECT a.name,
CASE WHEN b.name IS NOT NULL
THEN 'Started'
ELSE 'Stopped'
END AS current_state

[Code] ....

The intention was to get a pareto chart, to see the top wait events in the session. I would also like to see amount of cpu used. Based on this tuning effort could be prioritized.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved