Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping 1

Status
Not open for further replies.

nisha23

Programmer
Sep 23, 2003
19
US
I need to sum values on the basis of 30 minute interval.
Suppose
val1 val2 val3 cdate
 
select sum(val1), ...,
convert(char(9),cdate,112) + convert(char(3),cdate,8) + case when datepart(mi,cdate) < 30 then '00' else '30' end
group by convert(char(9),cdate,112) + convert(char(3),cdate,8) + case when datepart(mi,cdate) < 30 then '00' else '30' end

or you might find it better to create a tally table with the intervals in it and join to that - it will give you the zeroes for no entries.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Thank you, yes my problem is resolved. This is exactly what I was asking for.
 
Please one more help!!
sql query for
Weekly 2 hours data
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top