来自数据库的每小时销售报告 [英] Hourly sale report from database
本文介绍了来自数据库的每小时销售报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有人,
我正在使用sql express,我有所有条目都在其中的表,现在我希望从该表生成报告.
它应该显示如下:
销售时间总数TotalAmount
9:00-10:00 2 1300
10:00-11:00 4 1500
11:00-12:00 9 3500
等等..
请告诉我怎么做.
谢谢与问候,
Mohi
Dear all,
i am using sql express, I have table where all the entries are going, now i want the report to be generated from this table.
it should show like this:
Time no of sales TotalAmount
9:00 - 10:00 2 1300
10:00 - 11:00 4 1500
11:00 - 12:00 9 3500
AND SO ON..
Please tell me how to do it.
Thanks & Regards,
Mohi
推荐答案
我认为此链接将为您提供帮助
^ ]
和
http://www.sqlusa.com/bestpractices2005/centurydateformat/ [
i think this link will help you
http://blog.sqlauthority.com/2009/08/06/sql-server-get-time-in-hourminute-format-from-a-datetime-get-date-part-only-from-datetime/[^]
and
http://www.sqlusa.com/bestpractices2005/centurydateformat/[^]
use case, datepart, group by statement to calculate no. of sales & TotalAmount.
Select cast(DATEPART(HH, Time) as varchar(10))+ ':00', COUNT(1), SUM(Amount) from DemoTable group by DATEPART(HH, Time)
请检查以上查询,这将帮助您编写查询
please check the above query this will help you to write your query
这篇关于来自数据库的每小时销售报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文