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

备考刷题,请到

CDA认证小程序

The table "t1" has three columns: "id," "name," and "salary." If "t1" represents a forum's posting information table, where "id" is the poster's ID, "name" is the post's title, and "salary" is the score awarded for each post on the forum. The statement to display how many posts each member has made 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)

The goal is to display the number of posts made by each member, so you need to use "group by id" to group by member ID and then count the number of "name" entries.

正确答案是:A: `select id, count(name) from t1 group by id;`

### 专业分析:
1. **A: `select id, count(name) from t1 group by id;`**
- 这条SQL语句的功能是按用户ID分组,并统计每个用户发布的帖子数量。
- `group by id` 用于将数据按用户ID进行分组。
- `count(name)` 用于统计每个分组中帖子的数量。
- 这正是问题所要求的功能:显示每个成员发布了多少帖子。

2. **B: `select id, count(name) from t1 group by id having count(name)>5;`**
- 这条SQL语句除了按用户ID分组并统计每个用户发布的帖子数量外,还增加了一个条件:只显示发布帖子数量大于5的用户。
- 虽然这条语句可以统计帖子数量,但它并不符合问题的要求,因为它过滤掉了帖子数量少于或等于5的用户。

3. **C: `select id, count(name) from t1 group by id having count(name)>5 order by count(name);`**
- 这条SQL语句与B类似,增加了一个排序功能:按帖子数量进行排序。
- 同样,它也不符合问题的要求,因为它过滤掉了帖子数量少于或等于5的用户。

4. **D: `select id, count(name) from t1 where id > 100 group by id;`**
- 这条SQL语句在按用户ID分组并统计每个用户发布的帖子数量之前,增加了一个条件:只统计用户ID大于100的用户。
- 这也不符合问题的要求,因为它只统计了部分用户。

综上所述,选项A是最符合问题要求的SQL语句。