Skip to main content
Post Undeleted by WT_W
added 41 characters in body
Source Link
WT_W
  • 767
  • 1
  • 7
  • 17

If you're not picky about having the seconds appearing inI'm a little confused by the grouped capturetime output3rd example there, you can accomplishis this with the below. If you needsupposed to be 1325? Based off the seconds you can add them back ontorequirements of capturing the endsum of the grouping substringsnapshotvalues, the below query should get what you're after.

select dateadd(minute,1,convert(varchar(20),capturetime)), SUMsum(snapshotvalue)
from snapshotdata sd
group by dateadd(minute,1,convert(varchar(20),capturetime))

Alternatively you can play around with the datetime conversion to varchar options that are documented here:

http://msdn.microsoft.com/en-us/library/ms187928.aspx

If you're not picky about having the seconds appearing in the grouped capturetime output, you can accomplish this with the below. If you need the seconds you can add them back onto the end of the grouping substring.

select convert(varchar(20),capturetime), SUM(snapshotvalue)
from snapshotdata
group by convert(varchar(20),capturetime)

Alternatively you can play around with the datetime conversion to varchar options that are documented here:

http://msdn.microsoft.com/en-us/library/ms187928.aspx

I'm a little confused by the 3rd example there, is this supposed to be 1325? Based off the requirements of capturing the sum of the snapshotvalues, the below query should get what you're after.

select dateadd(minute,1,convert(varchar(20),capturetime)), sum(snapshotvalue)
from snapshotdata sd
group by dateadd(minute,1,convert(varchar(20),capturetime))
Post Deleted by WT_W
Source Link
WT_W
  • 767
  • 1
  • 7
  • 17

If you're not picky about having the seconds appearing in the grouped capturetime output, you can accomplish this with the below. If you need the seconds you can add them back onto the end of the grouping substring.

select convert(varchar(20),capturetime), SUM(snapshotvalue)
from snapshotdata
group by convert(varchar(20),capturetime)

Alternatively you can play around with the datetime conversion to varchar options that are documented here:

http://msdn.microsoft.com/en-us/library/ms187928.aspx