SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 daily sales by each hour and grand total
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

usafelix
Posting Yak Master

Hong Kong
103 Posts

Posted - 08/21/2014 :  11:51:02  Show Profile  Reply with Quote
I'm trying to get revenue by hour in one table. I would like to get the following columns and sku is contain of '%baby or oil%' and the hour from morning at 8:00 am to 22:00 pm and time range in below: please help to write a sql query .

08:00 - 09:00
09:00 - 10:00
10:00 - 11:00
11:00 - 12:00
12:00 - 13:00
21:00 - 22:00

StoreID, TransactionDate, TransactionHour, sku, TotalSales
A shop 20140821 13:00-14:00 oil $100
A shop 20140821 13:00-14:00 baby $100
Total $200

B shop 20140821 15:00-16:00 kid baby $250
B shop 20140821 21:00-22:00 skin oil $150
Total $400
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000