我需要创建一个报告(SSRS),但我不知道如何获得一个特定的值。请考虑以下情况:我有一个等级国家->城市->个人,我需要在一个列中得到特定人、特定城市和特定国家的财富价值。一个国家的财富不是生活在该国的人的财富总和。我的报告应该是:
美国:2000万美元
NY: 3M$ Person1: 0,1M$
Person2: 0,2M$
Boston: 2M$
Person 3: 0,5M$.我的问题是:
;WITH wealth_TEMP AS
(
SELECT
fo.wealthId,
SUM(fo.wealth) AS wealth
FROM
(
SELECT
wealthId,
CASE
WHEN (Some Criteria)
THEN 1
ELSE 0
END AS wealth
FROM wealthTable f
) fo
GROUP BY wealthId
),
Hierarchy AS
(
SELECT
B.CityId AS CityId,
B.CountryName AS CountryName
FROM HierarchyTable AS B where
b.CountryName IN (@Country)
),
Person_Table AS
(
SELECT
fsu.individualId,
fsu.Cityid,
fo.welth
FROM Individual_Table FSU
LEFT OUTER JOIN wealth_TEMP fo ON fo.wealthId = fsu.individualId
WHERE bu.Cityname IN (@City)
)
Select ......................发布于 2017-09-08 15:39:56
考虑到dataset返回类似的内容:
Country CountryWealth State StateWealth Person PersonWealth
USA 20M$ NY 3M$ Person 1 0,1M$
USA 20M$ NY 3M$ Person 2 0,2M$
USA 20M$ Boston 2M$ Person 3 0,5M$将表排序到国家、州、人梅,您需要添加更多的列并合并以获得所需的lyout
https://stackoverflow.com/questions/46118343
复制相似问题