我在该查询中编写了命名查询,我有诸如 request_id、createddate、confirmeddate、reporteddate、sitename、ticketstatusname 等属性......
我想知道 request_id 的票状态名称,即打开或关闭。我已将特定日期过滤为 ReportedDate='2011-07-31 00:00:00.000' 的日期25 个 request_id 是打开的,225 个 request_id 是关闭的。我在 ssas 多维数据集中复制和过去的相同查询,当我将站点名称、ticketstatusname 拖放到多维数据集浏览器中时,我得到了正确的计数,但我得到了错误的票,即实际上关闭的票显示为打开状态。请你能帮助我为什么我的 ssas 多维数据集中的 request) id 的状态错误。以下是命名查询。
SELECT *
FROM
(SELECT d.Short_sitename AS Sitename,
f.Request_ID,
dt3.FullDateAlternateKey AS CreatedDate,
dt2.FullDateAlternateKey AS ConfirmedDate,
dt1.FullDateAlternateKey AS ReportedDate,
CASE
WHEN (dt2.FullDateAlternateKey IS NULL)
OR (dt1.FullDateAlternateKey<dt2.FullDateAlternateKey) THEN 'Open'
ELSE 'Closed'
END AS TicketStatusName,
FROM FactTicket AS f
LEFT OUTER JOIN DimTime AS dt3 ON dt3.TimeKey = f.Create_DateKey
LEFT OUTER JOIN DimTime AS dt2 ON dt2.TimeKey = f.Confirmed_DateKey
LEFT OUTER JOIN DimSite AS d ON d.Site_ID=f.Site_ID
LEFT OUTER JOIN DimTime AS dt1 ON dt1.FullDateAlternateKey BETWEEN dt3.FullDateAlternateKey AND DATEADD(d, - 1, DATEADD(mm, DATEDIFF(m, 0, ISNULL(dt2.FullDateAlternateKey, GETDATE())) + (12 - MONTH(ISNULL(dt2.FullDateAlternateKey, GETDATE())) + 1), 0))
WHERE (dt1.FullDateAlternateKey = DATEADD(d, - 1, DATEADD(mm, DATEDIFF(m, 0, dt1.FullDateAlternateKey) + 1, 0)))
AND (f.Type_ID1 IS NOT NULL)
AND (f.Type_ID2 IS NOT NULL)
AND (f.Type_ID3 IS NOT NULL) )A
WHERE ReportedDate='2011-07-31 00:00:00.000'
AND sitename='BOUZ'