=============================
Itemnumber| Check_ind| year
=============================
123 |Y | 2011
456 |Y | 2011
123 |Y | 2012
456 |Y | 2011
456 |Y | 2011
我想結果爲SQL結果到3桶由數
=====================
1| 2-3| 4
=====================
123| 456 |
我想指望每個itemnumber出現在表以及年= 2011,然後把它放進水桶總時間。我的itnitial認爲是這樣的:
SELECT case when count(Itemnumber)>=0 and <=1 then '1'
case when count(Itemnumber)>=2 and <=3 then '2-3'
else '4' end
from table where year = '2011'
你會如何希望得到的結果一樣,如果,兩個123和456時僅一次? –
您如何期待返回出現0次的ItemNumbers?另外,你想要在哪一列出現3?都? – APH
@ChorWaiChun我認爲結果是正確的,因爲123只在表格中顯示一次,並且年份= 2011,所以它屬於0-1桶 – love233126