#查詢名字以“王”開頭的學(xué)生信息队塘。
#select * from student where sname regexp '^王';
#查詢班長表中電話號中出現(xiàn)“98”數(shù)字的班長信息杠氢。
#select * from monitor where tel regexp '98';
#查詢英語系撒踪,數(shù)學(xué)系老師的教師號和教師名。
#select tno,tname from teacher where sdept in('英語系','數(shù)學(xué)系');
#查詢總?cè)藬?shù)呈昔。
#select count(*) from student;
#查詢選修了課程的學(xué)生人數(shù)。
#select count(distinct sno) from sc where grade is not null;
#計(jì)算1號課程的學(xué)生平均成績。
#select avg(grade) from sc where cno='1';
#查詢選修了1號課程的學(xué)生最高分和最低分墙懂。
#select max(grade),min(grade) from sc where cno='1';
#查詢學(xué)號為“10001”的學(xué)生的總成績和平均成績。
#select sum(grade),avg(grade) from sc where sno='10001';
#查詢有考試成績的人數(shù)扮念。
#select count(distinct sno) from sc where grade is not null;
#統(tǒng)計(jì)各系教師人數(shù)损搬。
#select sdept,count(*) from teacher group by sdept;
#統(tǒng)計(jì)學(xué)生表中男,女學(xué)生人數(shù)柜与。
#select count(*) from student group by sex;
#統(tǒng)計(jì)每個(gè)班級中男巧勤,女人數(shù)。
#select sclassNo,sex,count(*) from student group by sclassNo,sex;
#統(tǒng)計(jì)教師表中系別的副教授人數(shù)弄匕。
#select sdept,count(*) from teacher where professional='副教授' group by sdept;
#select sdept,count(*),professional from teacher group by sdept,professional having professional='副教授';