Я не знаю, как объединить два набора данных в одну круговую диаграмму. Вместо этого я бы рекомендовал объединить ваши наборы данных в один новый набор данных, который можно использовать в круговой диаграмме.
Используя ваш пример продаж кошек и собак по месяцам, я создал пример того, как объединить 2 набора данных вместе.
Вы можете использовать столбец «total_sales» в финальном запросе, чтобы заполнить значения круговой диаграммы, и вы можете использовать «month_of_sale» в качестве группы серий.
-- Create temp table to store Cat sales data
DECLARE @catSales TABLE(
Sales INT
, MonthOfSale INT);
-- Create temp table to store Dog sales data
DECLARE @dogSales TABLE(
Sales INT
, MonthOfSale INT)
--Populate cat sales table with data
INSERT INTO @catSales
( Sales, MonthOfSale )
VALUES ( 50, -- Sales - int
1 -- MonthOfSale - int
)
INSERT INTO @catSales
( Sales, MonthOfSale )
VALUES ( 100, -- Sales - int
2 -- MonthOfSale - int
)
INSERT INTO @catSales
( Sales, MonthOfSale )
VALUES ( 75, -- Sales - int
3 -- MonthOfSale - int
)
--Populate dog sales table with data
INSERT INTO @dogSales
( Sales, MonthOfSale )
VALUES ( 150, -- Sales - int
1 -- MonthOfSale - int
)
INSERT INTO @dogSales
( Sales, MonthOfSale )
VALUES ( 80, -- Sales - int
3 -- MonthOfSale - int
)
INSERT INTO @dogSales
( Sales, MonthOfSale )
VALUES ( 200, -- Sales - int
4 -- MonthOfSale - int
)
--View data in cat sales table (note that months 1, 2, and 3 are all populated with data, but not month 4.
SELECT Sales
, MonthOfSale
FROM @catSales
--View data in dog sales table (note that months 1, 3, and 4 are all populated with data, but not month 2.
SELECT Sales
, MonthOfSale
FROM @dogSales
--Join the data from Cat and Dog sales together based on the month
SELECT cs.sales AS 'cat_sales'
, ds.sales AS 'dog_sales'
, ISNULL(cs.sales, 0) + ISNULL(ds.sales, 0) AS 'total_sales' -- Use ISNULL to convert missing data into 0 so that it adds correctly
, ISNULL(cs.MonthOfSale, ds.MonthOfSale) AS 'month_of_sale' -- If there are not cat sales, then the cs.MonthOfSale will be null and ds.MonthOfSale should be used instead
FROM @catSales cs
FULL OUTER JOIN @dogSales ds ON cs.MonthOfSale = ds.MonthOfSale -- Use full outer join to include all data from both tables
person
Jesse Potter
schedule
06.10.2014
LOOKUP
в SSRS. - person Jamie F   schedule 18.09.2014