March 18th, 2013, 05:46 AM
I have a DB with a column in a table holding duration times. I would like to compose a SQL which gives me the count of defined ranges of durations.
Lets say 0 - 60 minutes, 61 to 180 minutes, 181 - 600 minutes and 601 and above are the ranges and I need the counts of each range in one SQL-statement.
Is there a way to achieve this? In the moment I am too blind to see...
Thanx for any hint!
March 18th, 2013, 08:07 AM
You can use a case expression
Change names as apropriate.
select sum(case when <columnHoldingdurationTimes> between 0 and 60 then 1 else 0 end),
sum(case when <columnHoldingdurationTimes> between 61 and 180 then 1 else 0 end), ...
March 18th, 2013, 08:28 AM
grrr...sure - that's a way. As I wrote: too blind to see...
Originally Posted by swampBoogie
Thanx a lot!