day1python
學生表操做:mysql
1. 查詢出班級205有多少個男生sql
2. 查詢出名字爲4個字的全部學生信息(編號、姓名,年齡,班級)數據庫
3. 查詢出全部姓王的學生信息(編號、姓名,年齡,班級)django
4. 查詢出班級編號爲201,202,203的女生總人數flask
5. 查詢出學號整十的全部女生信息(姓名、年齡、我的簡介)spa
6. 刪除301班級中年齡在23歲以上的學生信息code
7. 把一個叫'衛然'的學生的姓別改爲女的blog
8. 把401班級中的姓名爲'吳傑'的學生信息刪除排序
9. 計算305班中全部學生的平均年齡以及他們的最大年齡和最小年齡
10. 查詢401,402,403,404,405中全部學生的年齡平均值
11. 查詢出全部學生中"白"的學生信息,並對他們使用年齡進行升序排列
12. 添加如下學生記錄到數據表中
姓名 年齡 性別 班級 個性簽名
張三丰 22 1 301 我是武當老闆
張翠山 21 1 302 我是武當老闆的五弟子
張無忌 20 1 302 明教老闆
13. 查詢年齡在18-20之間的姓李的女生
14. 查詢年齡在18-20之間的全部女生,並按照編號進行降序排序
15. 查詢出301,302,303,304,305,306中每一個班級總人數。
成績表操做
16. 查詢出學號爲9的學生的總成績
17. 查詢出課程編號爲4的課程平均成績
18. 查詢出學號爲6的學生的全部成績,並顯示對應的課程編號。
19. 查詢出課程編號爲20的課程成績,並進行分數的降序排列,顯示10個成績便可。
20. 查詢出學號爲1,2,3,4,5,6這幾個學員的平均成績。
21. 查詢出證成績表中每一個學科的平均成績。
day2
python操做數據庫
1. 查詢student表的全部記錄
2. 查詢student表的第2條到第4條記錄
3. 查詢全部學生的學號(id)、姓名(name)和報讀課程(department)的信息
4. 刪除305班年齡最小的學生
5. 修改id爲66的學員的姓名爲男
SQL語句編寫
1. 查詢Django課程和Django項目的全部學生的信息[學號,姓名,年齡,成績]
mysql> select a.id,name,age,achievement -> from student as a -> left join achievement as b -> on a.id = b.sid -> left join course as c -> on b.cid = c.id -> where c.course like 'Django%';
2. 查詢id=5的老師的全部學生信息[學號、姓名、年齡]
mysql> select a.id,a.name,a.age -> from student as a -> left join achievement as b -> on a.id = b.sid -> left join course as c -> on b.cid = c.id -> left join lecturer as d -> on c.lecturer_id = d.id -> where d.id =5;
3. 查詢306班、30七、308班中成績及格的學生
mysql> select a.name,a.age,a.sex,c.course,b.achievement -> from student as a -> left join achievement as b -> on a.id= b.sid -> left join course as c -> on b.cid = c.id -> where a.class in (306,307,308) and b.achievement >=60;
4. 查詢python成績及格的全部學生信息[學號、姓名、年齡、班級]
mysql> select a.id,a.name,a.age,a.class,b.achievement -> from student as a -> left join achievement as b -> on a.id = b.sid -> left join course as c -> on b.cid = c.id -> where c.course='python' and b.achievement >=60;
5. 查出全部女生的平均成績和報讀課程。
mysql> select c.course,avg(b.achievement) -> from student as a -> left join achievement as b -> on a.id = b.sid -> left join course as c -> on b.cid = c.id -> where a.sex =2 group by c.course;
6. 查詢出女生人數最多的5個課程。
mysql>select c.course,c.id,count(a.id) -> from student as a -> left join achievement as b -> on a.id = b.sid -> left join course as c -> on b.cid = c.id -> where a.sex =2 group by c.course order by count(a.id) desc, c.id asc limit 5;
7. 查詢出報讀flask課程的學生中女生的數量
mysql> select count(a.id) -> from student as a -> left join achievement as b -> on a.id = b.sid -> left join course as c -> on b.cid = c.id -> where c.course ='flask' and a.sex =2;
8. 查詢出 趙華 報讀的課程信息[ 上課老師名字,課程分數,平均分 ]
mysql> select d.name,c.course,b.achievement,avg(b.achievement) -> from student as a -> left join achievement as b -> on a.id = b.sid -> left join course as c -> on b.cid = c.id -> left join lecturer as d -> on c.lecturer_id = d.id -> where a.name = '趙華' group by c.course;
9.查出 401 班全部學生的 平均分和總分[分組查詢]。
mysql> select c.course,avg(b.achievement),sum(b.achievement) -> from student as a -> left join achievement as b -> on a.id= b.sid -> left join course as c -> on b.cid = c.id -> where a.class=401 group by c.course;
10.查出報讀了flask、django課程中年齡在21到23歲之間的全部男生的成績
mysql> select c.course,avg(b.achievement) -> from student as a -> left join achievement as b -> on a.id = b.sid -> left join course as c -> on b.cid = c.id -> where c.course in ('flask','django') and a.age between 21 and 23 group by c.course;
11.查處總分在200分以上的全部學生的姓名、班級
select a.class,a.name,sum(b.achievement) from student as a left join achievement as b on a.id = b.sid group by a.id having sum(b.achievement)>200 order by sum(b.achievement) desc ;
ok