sql - hourly sales report with time formatting -


this code:

select      system_time or_time,      sum (amount) hourly_sales       t_sales_detail      outlet_no = 20193 , system_date  = '6/2/2014' , void = 'n'  group      system_time 

and output this:

or_time   hourly_sales 12:00   295 13:00   2122.86 14:00   2230 15:00   1800 16:00   3090 17:00   880 18:00   652.86 

but output want see this:

or_time             hourly_sales 12:00pm-12:59pm     295 1:00pmpm-1:59       2122.86 2:00pm-2:59pm           2230 3:00pm-3:59pm       1800 4:00pm-4:59pm       3090 5:00pm-5:59pm       880 6:00pm-6:59pm       652.86 

i'm using visual studio 2010 , sql server 2008.

thank much.

you can use dateadd end range, , use convert convert time 12 hour time;

select convert(varchar(7), system_time, 100) + '-' +        convert(varchar(7), dateadd(s, 3599, system_time), 100) or_time,        sum (amount) hourly_sales t_sales_detail outlet_no = 20193 , system_date  = '6/2/2014' , void = 'n'  group system_time 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -