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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Getting a count based on value ranges

Author  Topic 

pithhelmet
Posting Yak Master

183 Posts

Posted - 2007-09-28 : 10:34:15
Hi everyone,

I have a dump of sql performance matrix

The column in question is duration

I need to get a count of records that
fall between these ranges...

< .02 sec.
.02 to .1 sec.
.1 to .5 sec
.5 to 5.0 sec.
> 5.0 sec.

what would the query be to get these counts??

thanks
tony

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-09-28 : 10:37:42
[code]
select
sum(case when duration < .02 then 1 else 0 end) as [< .02 sec],
sum(case when duration >= .02 and < .1 then 1 else 0 end) as [.02 to .1 sec]
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

pithhelmet
Posting Yak Master

183 Posts

Posted - 2007-09-28 : 12:36:33
PERFECT!!!

thank you!

Go to Top of Page
   

- Advertisement -