我有 2 个查询,带有参数。我可以让他们单独报告,但是我想要一份报告中的两个表格。问题是,使用参数的子报表似乎有问题......我的 2 个查询是:
SELECT A.Store_Number, A.GC_Sold, B.Total_Cars
FROM (SELECT Store_Number, COUNT_BIG(Quantity_Sold) AS GC_Sold
FROM Invoice_Detail_Tb
WHERE (Invoice_Date BETWEEN CONVERT(DATETIME, @startdate, 102) AND CONVERT(DATETIME, @enddate, 102)) AND (JLI_Category_Code = 'gc') AND (Invoice_Detail_Code LIKE 'jlgc%') AND (Invoice_Detail_Type = 'Item')
GROUP BY Store_Number) AS A INNER JOIN
(SELECT Store_Number, SUM(Vehicle_Count) AS Total_Cars
FROM Daily_Sales_Tb
WHERE (Operations_Day BETWEEN CONVERT(DATETIME, @startdate, 102) AND CONVERT(DATETIME, @enddate, 102))
GROUP BY Store_Number) AS B ON A.Store_Number = B.Store_Number
此输出为我提供了日期范围的数据,如下所示:
Store gc sold total cars
1 5 8
2 6 9
3 7 10
我的第二个查询是:
SELECT A.Store_Number, A.GC_Sold, B.Total_Cars
FROM (SELECT Store_Number, COUNT_BIG(Quantity_Sold) AS GC_Sold
FROM Invoice_Detail_Tb
WHERE (Invoice_Date = CONVERT(DATETIME, @enddate, 102)) AND (JLI_Category_Code = 'gc') AND (Invoice_Detail_Code LIKE 'jlgc%') AND (Invoice_Detail_Type = 'Item')
GROUP BY Store_Number) AS A INNER JOIN
(SELECT Store_Number, SUM(Vehicle_Count) AS Total_Cars
FROM Daily_Sales_Tb
WHERE (Operations_Day = CONVERT(DATETIME, @enddate, 102))
GROUP BY Store_Number) AS B ON A.Store_Number = B.Store_Number
此输出仅返回 enddate 的数据。并且看起来与上表相同。
用户在 Windows 窗体上选择开始日期和结束日期并按下“开始”。然后将参数传递给报告查看器......有什么想法吗?