我已经给出了多次,但似乎没有工作。这可能吗?以下是我目前的尝试:如何在公用表格表达式(CTE)中执行SUM()函数
With PrintsPerDayPerEmp(ID,[Month],[Day],[Year], [Number Of Prints])
AS
(Select ID,
datepart(month,Agent_Local_Time) as [Month],
datepart(day,Agent_Local_Time) as [Day],
datepart(year,Agent_Local_Time) as [Year],
count(RowID) as [Number of Prints]
From Table1
Where Agent_Local_Time >= (getdate()-90)
Group by datepart(day,Agent_Local_Time),
datepart(month,Agent_Local_Time),
datepart(year,Agent_Local_Time),
ID
)
select *
from PrintsPerDayPerEmp
where [Number Of Prints] > (sum([Number Of Prints])/90)*3
order by ID desc
所以我们展示你的'goes',你到底希望我们做什么? – sagi
对不起:)添加了它。 – RoflWaffle17
我想这里的逻辑显然会给我整列的总和作为一个数字,但我希望它显示发现每个ID的总和....如果这是有道理的。 – RoflWaffle17