我遇到了MS Access上的SQL问题..
问题是,我有: 可以作为一个人重复的周在同一周内有两个不同的部门,或销售渠道,区域经理名称或两者。
我想要什么?我希望在我有更大数额的同一周内总计总入口数量等(有70种不同)...
很好,设法做到这一点,但是,当在一个确定的一周内,它们重复了一周的时间内,总的入口和创建的SR是相等的。我没有第三个值将它放在这里,也许使用第一个,但是我不知道怎么做..:/
任何人都知道如何管理它?
我的SQL吼叫,谢谢!
SELECT
Raw.[NT Login],
Raw.[Fiscal Week],
MaxDuplicate.[Manager Name],
MaxDuplicate.[Area Manager Name],
MaxDuplicate.[Sales Channel],
MaxDuplicate.Department,
Raw.[Fiscal Month Name],
Raw.[Fiscal Quarter],
MaxDuplicate.[Functional Name],
Raw.Location,
Raw.Partner,
MaxDuplicate.Queue,
MaxDuplicate.[Queue Status Desc],
Raw.[Sub Region],
Sum(Raw.[SRs Created]) AS [SRs Created],
Sum(Raw.[Total Inbounds]) AS [Total Inbounds],
Raw.[Weekly Lag]
FROM Raw
INNER JOIN
(SELECT Raw.[NT Login],
Raw.[Fiscal Week],
Raw.[Manager Name],
Raw.[Area Manager Name],
Raw.[Sales Channel],
Raw.Department,
Raw.[Functional Name],
Raw.Queue,
Raw.[Queue Status Desc]
FROM Raw
INNER JOIN
(SELECT
Raw.[NT Login],
Raw.[Fiscal Week],
MAX(Raw.[Total Inbounds]) AS [Total Inbounds],
MAX(Raw.[SRs Created]) AS [SRs Created]
FROM Raw
GROUP BY Raw.[NT Login], Raw.[Fiscal Week]) AS Max
ON Raw.[NT Login] = Max.[NT Login]
AND Raw.[Fiscal Week] = Max.[Fiscal Week]
WHERE
Raw.[Total Inbounds] = Max.[Total Inbounds]
AND Raw.[SRs Created] = Max.[SRs Created]) AS MaxDuplicate
ON Raw.[NT Login] = MaxDuplicate.[NT Login]
AND Raw.[Fiscal Week] = MaxDuplicate.[Fiscal Week]
GROUP BY Raw.[NT Login],
Raw.[Fiscal Week],
MaxDuplicate.[Manager Name],
MaxDuplicate.[Area Manager Name],
MaxDuplicate.[Sales Channel],
MaxDuplicate.Department,
Raw.[Fiscal Month Name],
Raw.[Fiscal Quarter],
MaxDuplicate.[Functional Name],
Raw.Location,
Raw.Partner,
MaxDuplicate.Queue,
MaxDuplicate.[Queue Status Desc],
Raw.[Sub Region],
Raw.[Weekly Lag]