Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 drawing histogram/chart

Author  Topic 

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2008-05-08 : 13:05:35
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 :)

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-08 : 13:07:17
Which is your front end? Is this for reporting purpose? Then you can draw any type of chart using chart tool in SQL reporting services.
Go to Top of Page

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2008-05-08 : 13:09:30
SSRS offers tremendous and lovely tools to do it :)

But in this case my front-end is SSMS or any txt format :( Using sql server 2005
Go to Top of Page
   

- Advertisement -