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

备考刷题,请到

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 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)

id is the poster's unique ID. To get post count per member, group by id to partition by id, and count(name) counts number of names in each partition.

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

专业分析:

- 选项A:`select id, count(name) from t1 group by id;` 这条语句的作用是按id分组,然后统计每个id对应的帖子数量。它能够正确地显示每个成员发布的帖子数量。

- 选项B:`select id, count(name) from t1 group by id having count(name) > 5;` 这条语句在分组后增加了一个条件,即只有发布帖子数量超过5的成员才会被显示出来。虽然这也是一种统计方式,但它并不符合题目要求的“显示每个成员发布的帖子数量”。

- 选项C:`select id, count(name) from t1 group by id having count(name) > 5 order by count(name);` 这条语句不仅增加了一个条件,还对结果进行了排序。与选项B一样,它并不符合题目要求的“显示每个成员发布的帖子数量”。

- 选项D:`select id, count(name) from t1 where id > 100 group by id;` 这条语句在分组前增加了一个条件,即只有id大于100的成员才会被统计。这也不符合题目要求的“显示每个成员发布的帖子数量”。

因此,最符合题目要求的选项是A。