lmmp.net
当前位置:首页 >> sql语句 面试题 >>

sql语句 面试题

A.创建表格CODE省略 注明:学生表PK stu_id 课程表pk cos_id 分数表PK enrollment_id FK stu_id,cos_id B.插入数据code省略 C.Query select s.stu_id,stu_name,count(cos_id) from student s,enrollments e where s.stu_id = e.stu_id and e.gra...

我也不知道 哈哈哈,因为这是我没上过

SELECT *,( SELECT COUNT(*) FROM (SELECT COUNT(*),b.sid FROM sc b LEFT JOIN course c ON b.Cid=c.Cid GROUP BY b.sid,c.tid ) ow WHERE ow.sid = a.sid ) as '选课数量',(SELECT sum(Score) FROM Sc d WHERE a.sid = d.sid )as '总成绩' FRO...

a)selectpnameas'商品名',avg(qty)as平均销售量froms,p,mwherem.city='上海'ands.mno=m.mnoandp.pno=s.pno,selectp.Pno,p.pname,sum(s.qty)fromsleftjoinpons.pno=p.pnoleftjoinmonp.Mno=m.Mnowherem.city='上海市'groupbyp.Pno,p.pname,p.city...

5.1 select a.username,b.deptname from users a,dept b where a.dept_id=b.id; 5.2 update users set dept_id='9' where dept_id='2'; 5.3 select a.deptname,b.count_id from dept a,(select dept_id,count(id) as count_id from users group ...

select a.user_job as "职业",b.man_num as "男性人数",c.woman_num as "女性人数",count(id) as "总人数" from user a left join (select user_job,count(id) as man_num from user where user_sex=1 group by user_job) b on a.user_job=b.use...

SELECT DISTINCT 每个任务所有者当日的总结果数/当日总结果数, 每个任务所有者当日的总任务数/当日总任务数, task_owner FROM ( SELECT SUM(result_num) over(PARTITION BY 时间字段截取到日期,result_server) 当日总结果数, SUM(result_num) ov...

(1)统计有学生选修的课程门数 select count(distinct c#) from SC 2)求选修C4课程的女学生的平均年龄 select avg(s.age) --最好都带上前缀,养成好习惯 from s,c,sc where s.s#=sc.s# and c.c#=sc.c# and c.cname='C4' and s.sex='女'--字符类型...

比如学生表,有学号,姓名,年龄,性别这四个字段 select a.学号,a.姓名,a.年龄,a.性别,sum(c.成绩) as 总成绩from 学生表 a,成绩表 b,选课表 c where a.学号=b.学号and b.课程号=c.课程号group by a.学号,a.姓名,a.年龄,a.性别order by a.姓名 ...

我使用的是MySQL 如下语句: 建表语句: create table Lessoninfo( no int, week int, isonduty char); 插入数据:略 insert into Lessoninfo values(...............) SQL查询语句: select no as '教师号', sum(week=1) as '星期一',sum(week=...

网站首页 | 网站地图
All rights reserved Powered by www.lmmp.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com