考试报名
考试报名
考试内容
考试大纲
在线客服
返回顶部

备考刷题,请到

CDA认证小程序

Table t1 has id, name and salary columns. If t1 is a post info table for a forum, with id as the poster's ID, name as post title, and salary as points awarded by the forum per post, then: The statement to show members who have made more than 5 posts is:
A. select id ,count(name)from t1 group by id;
B. select id ,count(name)from t1 group by id having count(name)>5;
C. select id ,count(name)from t1 group by id having count(name)>5 order by count(name);
D. select id ,count(name)from t1 where id > 100 group by id;
上一题
下一题
收藏
点赞
评论
题目解析
题目评论(0)

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是最符合题目要求的正确答案。