我想写一个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