我想寫一個SQL查詢,我需要的分數> 3的縣數,然後在該列表上的縣,我需要產生一個百分比的房間分數< 3.所以我需要三列,縣名,由縣級得分> 3#,配有得分< 3%的縣SQL查詢與百分比和聚合函數
SELECT County = c.Description, [Score > 3] = count(s.Score),
((select count(room.Name) where s.Score< 3) /(select count(room.Name)) * 100)
FROM Sites AS s
inner join Profiles as p on s.Profile_Id = p.Id
inner join Counties as c on p.County_Id = c.Id
inner join Rooms as room on s.Id = room.Site_Id
where s.Score > 3
Group By c.Description
你現在有什麼問題? – 2013-03-26 17:31:33
問題是查詢。第三列,分數<3的房間的百分比...不能指出 – user1220099 2013-03-26 17:33:03