表名
student(S#,Sname,Sage,Ssex)學生表 S#:學號;Sname:學生姓名;Sage;學生年齡;Ssex:學生性別
Course(C#,Cname,T#) 課程表 C#:課程編號;Cname:課程名字;T#:教師編號
SC(S#,C#,score)成績表 S#:學號;C#:課程編號;score:成績
Teacher(T#,Tname)教師表 T#:教師編號;Tname:教師名字
問題1:查詢“001”課程比“002”課程成績高的所有學生的學號;
問題2:查詢沒學過“葉平”老師課的同學的學號,姓名
問題3:洗掉學習“葉平”老師課的SC表記錄
問題4:把“sc”表中“葉平”老師教的課的成績都更改為此課程的平均成績
uj5u.com熱心網友回復:
大致寫了一下, 沒有校驗。下次最好提供建表的腳本和測驗資料,這樣方便點select distinct a.s#, s.sname
from sc a,
sc b,
student s
where a.s# = b.s#
and a.s# = s.s#
and a.c# = '001'
and b.c# = '002'
and a.score > b.score;
select distinct s.s#, s.sname
from sc,
student s
where sc.s# = s.S#
and not exists ( select 1
from course c,
teacher t
where c.t# = t.t#
and c.c# = sc.c#
and t.tname = '葉平') ;
delete from sc
where exists ( select 1
from course c,
teacher t
where c.t# = t.t#
and c.c# = sc.c# );
update sc
set sc.score = ( select avg(score)
from sc c
where sc.c# = c.c# )
where exists ( select 1
from course c,
teacher t
where c.t# = t.t#
and c.c# = sc.c# );
uj5u.com熱心網友回復:
后面兩個sql 少寫了葉平條件,下面補充了一下delete from sc
where exists ( select 1
from course c,
teacher t
where c.t# = t.t#
and c.c# = sc.c#
and t.tname = '葉平');
update sc
set sc.score = ( select avg(score)
from sc c
where sc.c# = c.c# )
where exists ( select 1
from course c,
teacher t
where c.t# = t.t#
and c.c# = sc.c#
and t.tname = '葉平' );
uj5u.com熱心網友回復:
大神我想再問你問題,跪求大神解答使用A charindex 函式的運用,在表store中name欄位的“美”字分別在第幾個位置?(寫出具體sql陳述句)?
用上面的變數賦值表示上月第一天,上月今天,今月第一天和今天(寫出具體sql陳述句)
uj5u.com熱心網友回復:
ORACLE沒有charindex函式,你說的SQL SERVER。這里是ORACLE版塊uj5u.com熱心網友回復:
我還有一題不知道怎么解,麻煩你幫我解決一下,多謝了Oracle資料庫表存在偽列rowid,請利用rowid撰寫一個sql陳述句,從以下記錄中找到唯一記錄,并將其flag列更新為Y
No name sex flag
1 張三 1 N
1 張三 1 N
1 張三 1 N
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/62097.html
標籤:高級技術
