CREATE TABLE interview (uniqueID int identity(1,1),
date datetime,
recordtype int,
amount numeric(18, 4))
INSERT INTO interview values('6/30/13', 1, 27.95)
INSERT INTO interview values('5/20/13', 1, 21.85)
INSERT INTO interview values('5/22/13', 2, 27.90)
INSERT INTO interview values('12/11/12', 2, 23.95)
INSERT INTO interview values('6/13/13', 3, 24.90)
INSERT INTO interview values('6/30/13', 2, 27.95)
INSERT INTO interview values('5/20/13', 2, 21.85)
INSERT INTO interview values('5/22/13', 1, 27.90)
INSERT INTO interview values('12/11/12',1, 23.95)
INSERT INTO interview values('6/13/13', 3, 24.90)
INSERT INTO interview values('6/30/13', 3, 27.95)
INSERT INTO interview values('5/20/13', 3, 21.85)
INSERT INTO interview values('5/22/13', 2, 27.90)
INSERT INTO interview values('12/11/12', 1, 23.95)
INSERT INTO interview values('6/13/13', 1, 24.90)
如何獲得以下結果?查詢會是什麼樣子?SQL加入查詢如何到
我只能得到部分的工作,但我的答案是不正確的。我需要 以某種方式加入查詢。
select distinct date, count(RecordType)as Count_unique1
from interview
where RecordType = '1'
group by date
select distinct date, count(RecordType)as Count_unique2
from interview
where RecordType = '2'
group by date
select distinct date, count(RecordType)as Count_unique3
from interview
where RecordType = '3'
group by date
嘗試此鏈接:http://technet.microsoft.com/en-us/library/aa172756%28v = sql.80%29.aspx – SK2185
RecordType在所有情況下都是1,2,3,或者可能會有所不同? –