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)
 urgent edit query for hourly sales and total
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

usafelix
Yak Posting Veteran

Hong Kong
90 Posts

Posted - 08/21/2014 :  13:20:22  Show Profile  Reply with Quote
How to edit this query to output the time range by hourly from 8:00 to 23:00 pm.

I hope the result is
------------------------------
shopid date time range trx time item amount
A shop 20140821 08:00 - 09:00 08:15 am Apple $ 50
A shop 20140821 15:00 - 16:00 15:32 pm pie $ 20
A Shop total : 70

B shop 20140821 23:00 - 24:00 23:02 pm Apple $70

Grand total : $140
------------------------------------------------
SELECT CONVERT(varchar(13), xsodetail.txdate, 121) + ':00',xsodetail.dess as item, Sum(xsodetail.itemAmt) AS SalesAmount FROM xsodetail
WHERE xsodetail.txdate = Convert(varchar, GETDATE(),112)-3 and xsodetail.dess like '%[A-z]%'
GROUP BY CONVERT(varchar(13), xsodetail.txdate, 121), xsodetail.item
  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.23 seconds. Powered By: Snitz Forums 2000