2026/5/21 19:51:00
网站建设
项目流程
源代码如何做网站,学做沪江网站要多久,霸州网站设计,如何做内网站的宣传栏#26、查询每门课程被选修的学生数
select
count(a.s_id) as count_course , b.c_name
from
score a
left join
course b
on
a.c_id b.c_id
group by a.c_id书写怎么这么糟糕......#27、查询出只有两门课程的全部学生的学号和姓名select count(a.c_id),b.*from score a, stud…#26、查询每门课程被选修的学生数 select count(a.s_id) as count_course , b.c_name from score a left join course b on a.c_id b.c_id group by a.c_id书写怎么这么糟糕......#27、查询出只有两门课程的全部学生的学号和姓名 select count(a.c_id),b.* from score a, student b where a.s_id b.s_id group by a.s_id having count(a.c_id) 2#查询男生女生人数 select count(s_sex),s_sex from student group by s_sex666count总是搞不懂应该count谁用谁分类。-- 29、查询名字中含有风字的学生信息 select * from student where s_name like %风注意like 和 的区别-- 30、查询同名同性学生名单并统计同名人数 with t_table as (select count(s_name) over (partition by s_id order by count(s_name)) as count_name, s_name, s_id, s_sex from student group by s_id ) select s_name,s_sex,count(*) from t_table where count_name 1 group by s_id明显你写的很复杂看解析select a.s_name, a.s_sex, count(*) from student a JOIN student b on a.s_id !b.s_id and a.s_name b.s_name and a.s_sex b.s_sex GROUP BY a.s_name,a.s_sex首先两个表连接做笛卡尔积随后限定条件有【a.s_id ! b.s_id】这个条件出来就是异响匹配你写的时候没想到然后是两个连接条件再是【count*】是计算做出来的表格所有的行数也就是只符合条件的总人数。