After calculating posts per group (count(name)), we want to output results greater than 5 (count(name) > 5). Need HAVING here instead of WHERE after GROUP BY.
正确答案是:B: select id ,count(name) from t1 group by id having count(name)>5;
### 专业分析:
1. **选项A: `select id, count(name) from t1 group by id;`**
- 这个查询语句会返回每个用户的帖子数量,但不会过滤出发帖数超过5的用户。
2. **选项B: `select id, count(name) from t1 group by id having count(name)>5;`**
- 这个查询语句首先按照用户ID分组,然后计算每个用户的帖子数量。`having count(name)>5` 过滤条件确保只返回发帖数超过5的用户。
3. **选项C: `select id, count(name) from t1 group by id having count(name)>5 order by count(name);`**
- 这个查询语句与选项B类似,但多了一个排序操作。虽然这个语句也是正确的,但题目并没有要求排序,因此这个选项不是最优解。
4. **选项D: `select id, count(name) from t1 where id > 100 group by id;`**
- 这个查询语句会返回用户ID大于100的用户的帖子数量,但没有过滤出发帖数超过5的用户,因此不符合题目要求。
综上所述,选项B是最符合题目要求的正确答案。