题目描述:house表,字段如下:
id | 主键 |
room_id | 房间id |
owner_id | 房东id |
room_type | 整租为1,合租为0 |
求整租超过10个房子的房东id
sql:
select owner_id, count(room_id) num from house
where room_type=1
group by owner_id
having num >10;
note:
SQL会在分组之前计算where语句,在分组之后计算having语句.