Solved

SQL SERVER - Group by  15 minute increments

Posted on 2013-12-03
1
369 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

679 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