Solved

SQL SERVER - Group by  15 minute increments

Posted on 2013-12-03
1
364 Views
Last Modified: 2013-12-03
Hi..
I have a timestamp column - how can I group the records by 15 minutes increments?
I need to sum the records for each 15 minutes.
thx
0
Comment
Question by:JElster
1 Comment
 
LVL 11

Accepted Solution

by:
jasonduan earned 500 total points
ID: 39693021
Try this:

SELECT
  DATEADD(minute, DATEDIFF(minute, '1900-01-01', DateOrdered) /15 * 15, '1900-01-01')
  ,  SUM(OrderAmt)
FROM YourTable
GROUP BY
   DATEADD(minute, DATEDIFF(minute, '1900-01-01', DateOrdered) /15 * 15, '1900-01-01')

Open in new window

0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question