在您的选择查询中组合您的数据。您可以使用UNION 语句,如下例所示。
SELECT actual_sales AS 'sales'
, calendar_day AS 'calendar_day'
, 'actual' AS 'sales_type'
FROM actual_sales_data
UNION
SELECT projected_sales AS 'sales'
, calendar_day AS 'calendar_day'
, 'projected' AS 'sales_type'
FROM projected_sales_data
然后您可以将两种类型的销售(实际和预计)绘制成一条连续的线,因为这将是一个数据集。
以下是一些可用于示例查询的示例数据:
DECLARE @actual_sales_data TABLE (actual_sales int, calendar_day DATE)
DECLARE @projected_sales_data TABLE (projected_sales int, calendar_day DATE)
INSERT INTO @actual_sales_data
SELECT 100, '1/1/2016'
UNION
SELECT 200, '1/2/2016'
UNION
SELECT 150, '1/3/2016'
UNION
SELECT 180, '1/4/2016'
UNION
SELECT 210, '1/5/2016'
UNION
SELECT 230, '1/6/2016'
UNION
SELECT 200, '1/7/2016'
UNION
SELECT 220, '1/8/2016'
INSERT INTO @projected_sales_data
SELECT 220, '1/8/2016' -- This data point matches the last actual sales number so that SSRS will draw a continuous line
UNION
SELECT 250, '1/9/2016'
UNION
SELECT 220, '1/10/2016'
UNION
SELECT 180, '1/11/2016'
UNION
SELECT 250, '1/12/2016'
UNION
SELECT 210, '1/13/2016'
UNION
SELECT 270, '1/14/2016'
UNION
SELECT 200, '1/15/2016'
UNION
SELECT 290, '1/16/2016'
SELECT actual_sales AS 'sales'
, calendar_day AS 'calendar_day'
, 'actual' AS 'sales_type'
FROM @actual_sales_data
UNION
SELECT projected_sales AS 'sales'
, calendar_day AS 'calendar_day'
, 'projected' AS 'sales_type'
FROM @projected_sales_data