我正在尝试编写一个 sql 查询,其中我需要按县划分的分数数 > 3,然后对于该列表上的县,我需要生成分数 < 3 的房间百分比。所以我需要三列,县名称,# of各县得分 > 3,各县得分 < 3 的房间百分比
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