日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

sql语句查询计算机系,SQL查询语句基础

發布時間:2024/8/1 数据库 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 sql语句查询计算机系,SQL查询语句基础 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.查詢全體學生的學號與姓名

select sno,sname

from student;

3.查詢全體學生的詳細信息

select *

from student;

4.查詢全體學生的姓名及其出生年份

select sname,2004-sage

from student;

5.查詢全體學生的姓名,出生年份和所在院系,要求用小寫字母表示所有系名

select sname,'year of birth:',2004-sage,lower(sdept)

from student;

6.查詢選修課程的學生學號,DISTINCT去掉重復行

select DISTINCT sno

from SC;

select sno

from SC;

等價于

select ALL sno

from SC;

7.查詢計算機科學系全體學生的名單

select sname

from student

where sdept='cs';

8.查詢所有年齡在20歲以下的學生姓名及其年齡

select sname,sage

from student

where sage<20;

9.查詢考試成績有不及格的學生的學號

select DISTINCT sno

from sc

where grade<60;

10.查詢年齡在20~23歲(包括20歲和23歲)之間的學生的姓名,系別和年齡

select sname,sdept,sage

from student

where sage between 20 and 23;

11查詢年齡不在20~23歲之間的學生的姓名,系別和年齡

select sname,sdept,sage

from student

where sage not between 20 and 23;

12.查詢計算機科學系cs,數學系ma和信息系is學生的姓名和性別

select sname,ssex

from student

where sdept in('cs','ma','is');

13.查詢不是計算機科學系cs,數學系ma和信息系is學生的姓名和性別

select sname,ssex

from student

where sdept not in('cs','ma','is');

14.查詢學號為200215121的學生的詳細情況

select *

from student

where sno like '200215121';

等價于

select *

from student

where sno='200215121';

15.查詢所有姓劉的學生的姓名,學號和性別

select sname,sno,ssex

from student

where sname like '劉%';

16.查詢所有不姓劉的學生的姓名,學號和性別

select sname,sno,ssex

from student

where sname not like '劉%';

17.查詢姓歐陽且全名為3個漢字的學生的姓名

select sname

from student

where sname like '歐陽_';

19.查詢DB_Design課程的課程號和學分

select cno,ccredit

from course

where cname like 'DB_Design'ESCAPE'';

ESCAPE''表示""為換碼字符。這樣匹配串中緊跟著""后面的字符"_"不再具有通配符的含義,轉義為普通的"_"字符

20.查詢以"DB_"開頭,且倒數第3個字符為i的課程的詳細情況

select *

from course

where cname like 'DB_%i__'ESCAPE'';

21.查詢缺少成績的學生的學號和相應的課程號

select sno,cno

from sc

where grade is null;

22.查詢計算機科學系年齡在20歲以下的學生姓名

select sname

from student

where sdept='cs' and sage<20;

23.查詢計算機科學系cs,數學系ma和信息系is學生的姓名和性別

select sname,ssex

from student

where sdept='cs' or sdept='ma' or sdept='is';

24.查詢選修了3號課程的學生的學號及其成績,查詢結果按分數的降序排序

select sno,grade

from sc

where cno='3'

order by grade DESC;

25.查詢全體學生情況,查詢結果按所在系的系號升序排列,同一系的學生按年齡降序排列

select *

from student

order by sdept,sage DESC;

26.查詢學生總人數

select COUNT(*)

from student;

27.查詢選修了課程的學生人數

select COUNT(DISTINCT sno)

from sc;

28.計算1號課程的學生的平均成績

select AVG(grade)

from sc

where cno='1';

29.查詢選修1號課程的學生的最高分數

select MAX(grade)

from sc

where cno='1';

30.查詢學生200215012選修課程的總學分數

select SUM(ccredit)

from sc,course

where sno='200215012' and sc.cno=course.cno;

31.求各個課程號及相應的選課人數

select cno,count(sno)

from sc

group by cno;

32.查詢選修了3門以上課程的學生學號

select sno

from sc

group by sno

having count(*) >3;

33.查詢每個學生及其選課情況

select student.*,sc.*

from student,sc

where student.sno=sc.sno;

35.查詢每一門課的間接先修課

select first.cno=second.cpno

from course first,course second

where first.cpno =second.cno;

36.

select student.sno,sname,ssex,sage,sdept,cno,grade

from student left out join sc on (student.sno=sc.sno);

37.查詢選修2號課程且成績在90分以上的所有學生

select student.sno,sname

from student,sc

where student.sno=sc.sno and

sc.cno='2' and sc.grade>90;

38.查詢每個學生的學號,姓名,選修的課程名及成績

select student.sno,sname,cname,grade

from student,sc,course

where student.sno=sc.sno and sc.cno=course.cno;

39.查詢與劉晨在同一系學習的學生

select sno,sname,sdept

from student

where sdept in

(select sdept

from student

where sname='劉晨');

等同于

select s1.sno,s1.sname,s1.sdept

from student s1,student s2

where s1.sdept=s2.sdept and

s2.sname='劉晨';

40.查詢選修了課程名為“信息系統”的學生學號和姓名

select sno,sname

from student

where sno in

(select sno

from sc

where cno in

(select cno

from course

where cname='信息系統'

)

);

等價于

select student.sno,sname

from student,sc,course

where student.sno=sc.sno and

sc.cno=course.cno and

course.cname='信息系統';

41.找出每個學生超過他選修課程平均成績的課程號

select sno,cno

from sc x

where grade>=(select AVG(grade)

from sc y

where y.sno=s.sno

);

42.查詢其他系中比計算機科學系某一學生年齡小的學生姓名和年齡

select sname,sage

from student

where sage

from student

where sdept='cs'

)

and sdept <> 'cs';

43.查詢其他系中比計算機科學系所有學生年齡都小的學生姓名及年齡

select sname,sage

from student

where sage < all

(select sage

from student

where sdept='cs'

)

and sdept <> 'cs';

44.查詢所有選修了1號課程的學生姓名

select sname

from student

where EXISTS

(select *

from sc

where sno=student.sno and cno='1');

使用存在量詞EXISTS后,若內層查詢結果非空,則外層的WHERE子句返回真值,否則返回假值

45.查詢沒有選修1號課程的學生姓名

select sname

from student

where not exists

(select *

from sc

where sno=student.sno and cno='1');

46.查詢選修了全部課程的學生姓名

select sname

from student

where not exists

(select *

from course

where not exists

(select *

from sc

where sno=student.sno

and cno=course.cno));

47.查詢至少選修了學生200215122選修的全部課程的學生號碼

select distinct sno

from sc scx

where not exists

(select *

from sc scy

where scy.sno='200215122' and

not exists

(select *

from sc scz where scz.sno=scx.sno and scz.cno=scy.cno));

48.查詢計算機科學系的學生及年齡不大于19歲的學生

select *

from student

where sdept='cs'

union

select *

from student

where sage<=19;

union會自動去掉重復元組,而union all操作符可以保存重復元組

49.查詢選修了課程1或者課程2的學生集合的并集

select sno

from sc

where cno='1'

union

select sno

from sc

where cno='2';

50.查詢計算機科學系的學生與年齡不大于19歲的學生的交集

select *

from student

where sdept='cs'

intersect

select *

from student

where sage<=19;

總結

以上是生活随笔為你收集整理的sql语句查询计算机系,SQL查询语句基础的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 日本黄动漫 | 日韩av在线看免费观看 | 免费日本黄色片 | 国产小精品 | 日韩在线观看免费高清 | 国产在线视频二区 | jizzjizz日本人 | 成了校长的性脔h文 | 日本精品一区二区三区在线观看 | 神马老子午夜 | 国产精品电影在线观看 | 日本在线不卡一区二区 | www四虎com | 大屁股白浆一区二区 | 米奇7777狠狠狠狠视频 | 超碰69 | 超碰p| 美女黄视频大全 | av簧片| 精品人妻一区二区三区四区久久 | jvid在线| 国产三级麻豆 | 久久伊人影视 | 99精品偷自拍 | 久久九九久精品国产免费直播 | 日韩久久久| 激情超碰在线 | 在线无遮挡| 日韩精品一线二线三线 | 国产精品成人一区二区网站软件 | 欧美日韩色综合 | 综合网在线观看 | 亚洲国产日本 | 精品视频免费在线 | a级欧美| 精品亚洲aⅴ无码一区二区三区 | 少妇高潮一区二区三区在线 | 波多野结衣三级视频 | 淫欲av | 男人日女人b视频 | 亚洲a影院| 性欧美在线视频观看 | 在线观看一二三区 | 中文字幕蜜臀 | 99精品视频免费在线观看 | 伊人av影院 | 青青草福利视频 | 在线免费日韩av | 国产视频一二三四区 | 欧美精品久久99 | 黄色av免费在线播放 | 久爱视频在线观看 | 97视频精品 | 偷拍亚洲欧美 | 片集网 | 久久精品性爱视频 | 99青青草 | 住在隔壁的她动漫免费观看全集下载 | 中文在线字幕免费观看电 | 尤物视频官网 | 国产精品区二区三区日本 | 美丽姑娘免费观看在线观看 | 天天干天天操天天碰 | 黑人毛片网站 | 97av在线视频| 欧美在线影院 | 成品短视频泡芙 | 美女网站黄频 | 四虎4hu | 奶罩不戴乳罩邻居hd播放 | 大度亲吻原声视频在线观看 | 大帝av| 无码人妻久久一区二区三区不卡 | 精品人妻少妇一区二区三区 | 亚洲av久久久噜噜噜熟女软件 | 国产农村妇女精品一区二区 | 曰女同女同中文字幕 | 一及黄色大片 | 中文国语毛片高清视频 | 欧美激情福利 | 日本一级三级三级三级 | 亚洲第一精品网站 | 老熟妇一区二区三区 | 黑人极品ⅴideos精品欧美棵 | 69社| 成人在线综合网 | 性xxx18| 中文字幕校园春色 | 亚洲一区二区国产精品 | 欧美成人午夜视频 | 性无码专区无码 | 国产调教视频在线观看 | 国产牛牛 | 国产白嫩美女无套久久 | 永久av在线免费观看 | 波多野吉衣av| 综合久久av | 亚洲乱熟女一区二区 | 天堂网中文在线 |