我有我的,看起來像這樣的查詢產生一個結果:過濾器由總和不進行分組
Select Employee, Month, (select case when Status = '---' then 0 Else 1 end) as PlaningValue
From PlanningTable PT
Where Month >= @From Month and Month <= @ToMonth
這樣的結果看起來是這樣的:
|Employee| Month | PlaningValue |
|George | 2014-01 | 1 |
|George | 2014-02 | 1 |
|George | 2014-03 | 0 |
|Andrew | 2014-01 | 0 |
|Andrew | 2014-02 | 1 |
|Andrew | 2014-03 | 0 |
|Howard | 2014-01 | 1 |
|Howard | 2014-02 | 1 |
|Howard | 2014-03 | 1 |
現在我想要什麼是以下內容:
過濾出在上述示例中,在三個月期間內總計劃值爲3, 的員工將被過濾掉。
有沒有一種方法可以很好地完成這項工作?
(注:因爲我要使用查詢的報表服務,我不能使用OVER功能)
謝謝大家的幫助
奇怪的CASE語法。爲什麼選擇它? – Alexander