A. sql查詢三門科目90分以上的學生
select name from table_name where grade>90 group by name having count(*)>2;
B. 從學生選課資料庫中查詢選修「資料庫原理」課並且成績在90分以上的學生名單,請寫出SQL語句.
select sname from student
where sno in(
select a.sno from studentcourse a join course b
on a.cno=b.cno
where b.cname='資料庫原理' and a.score>90)
select a.sclass as 班級,count(*) as 不及格人數 from
student a join studentcourse b
on a.sno=b.sno
where b.score<60
group by a.sclass
C. sql查詢語句的問題,「列出成績大於90的所有學生的姓名、專業、課程名稱、成績」這條語句怎麼寫
可以參考下面的代碼:
select s.姓名, s.專業, sc.成績, c.課程名稱
from 學生基本情況表 s, 成績表 sc, 課程表 c
where s.學號 = sc.學號 and c.課程編號 = sc.課程編號
and sc.成績 > 90
(3)sql90分以上的語句擴展閱讀:
sql語句
刪除列:
Alter table table_name drop column column_name--從表中刪除一列
添加主鍵:
Alter table tabname add primary key(col)
平均:
select avg(field1) as avgvalue from table1
最大:
select max(field1) as maxvalue from table1
D. 用SQL語句三種方法查詢秋季學期有2門以上課程獲90分以上成績的學生名
方法一:連接
select distinct sname from student,sc,course
where student.sno=sc.sno and course.cno=sc.cno
and grade>=90 and semester='秋'
group by student.sno having count(*)>=2
方法二:嵌套
select sname from student where sno in(
select sno from sc where grade>=90 and cno in(
select cno from course where semester='秋')
group by sno having count(*)>=2)
主要是以上兩種方法,其它方法都是用以上兩種方法演變過來,這里主要用group by sno 對每個學生進行分組,然後用having count(*)>=2對每組進行篩選.
方法三:
select sname from student,(
select sno from sc where grade>=90 and cno in(
select cno from course where semester='秋')
group by sno having count(*)>=2) t where student.sno=t.sno
方法四:
select sname from student where exists(
select * from sc where (
select count(*) from sc where sno=student.sno and grade>=90 and cno in
(select cno from course where semester='秋'))>=2)
類似的方法有很多,主要是連接法和嵌套法.
E. SQL語句查詢查看90分以上學生的成績.課程名稱.學生姓名怎麼寫
select 成績,課程名稱,姓名 from 成績,學生基本信息,課程名稱 where學生基本信息.學號=成績.學號 and 成績.課程編號=課程名稱.課程編號 and 成績>90