[英]Sql Query for an ssrs report
I have the following report I need to generate . 我需要生成以下报告。 I am new to SSRS. 我是SSRS的新手。
Number of Stores with June July Aug
0 sales 12 34 32
1 to 9 Sales 12 34 45
10+ sales 15 45 54
The tables I have are as follows : 我的表格如下:
Store :
YEAR MONTH StoreName
2013 10 ABC
2013 10 DEF
2013 09 JKL
2013 06 FGH
Store Sales : (Contains only stores whose sales are > 0)
YEAR MONTH StoreName NumberOfSales
2013 10 ABC 3
2013 09 JKH 14
2013 10 FRH 9
I am not really sure what I need to do to get the report in the above format ? 我不确定要以上述格式获取报告需要做什么? I can write a query for sales in a single month , but how do I write a query to get the report for all 3 months ? 我可以在一个月内编写一个销售查询,但是如何编写查询以获取所有三个月的报告? Or is there a better way to do these reports using ssrs ? 还是有更好的方法使用ssrs来做这些报告?
If you can direct me on what to do it will be great ? 如果您可以指导我该怎么做,那会很棒吗?
You want to set up your query like this: 您想要这样设置查询:
SELECT Year, Month, (CASE
WHEN NumberOfSales = 0 THEN '0 Sales'
WHEN NumberOfSales BETWEEN 1 AND 9 THEN '1-9 Sales'
WHEN NumberOfSales > 9 THEN '10+ Sales' END) [SaleGroup]
FROM FactStoreSales
Then you basically want to go into SSRS and just throw it into a table with the month in the columns and the group in the rows and let it pivot the data itself rather than trying to do that in SQL. 然后,您基本上想进入SSRS,将其放入表中,将月份放在列中,将组放在行中,然后让它透视数据本身,而不是尝试在SQL中做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.