SQL筆試題1
?

?2

?3

?4

?5

?6

?7

?8

?9

10

11

12








posted on 2006-12-21 18:05 youngturk 閱讀(3993) 評論(6) 編輯 收藏 所屬分類: SQL筆試題
?
posted on 2006-12-21 18:05 youngturk 閱讀(3993) 評論(6) 編輯 收藏 所屬分類: SQL筆試題
select sname, sum(case skemu when '語文' then sgrade else 0 end) as 語文,
sum(case skemu when '數學' then sgrade else 0 end) as 數學,
sum(case skemu when '英語' then sgrade else 0 end) as 英語
from students group by sname order by sname desc 回復 更多評論
select t1.姓名,t1.語文,t2.數學,t3.英語from
(select 姓名as 姓名,成績as 語文from t where 科目='語文') t1
join
(select 姓名as 姓名,成績as 數學from t where 科目='數學') t2
on t1.姓名=t2.姓名
join
(select 姓名as 姓名,成績as 英語from t where 科目='英語') t3
on t2.姓名=t3.姓名
回復 更多評論
樓主的,應該是這樣的吧-------------------------
select A.姓名,A.成績 as 語文,B.成績 as 數學,C.成績 as 英語
from student A,student B,student C
where A.姓名 = B.姓名 and B.姓名 = C.姓名
and A.科目 = ' 語文 ' and B.科目 = ' 數學 '
and C.科目 = ' 英語 ' 回復 更多評論
select distinct aa3.姓名,aa3.語文,aa3.數學,aa4.英語 from
(select distinct aa1.姓名,aa1.語文,aa2.數學 from
(select 姓名,成績 as 語文 from Table_name where 科目='語文') aa1
left join
(select 姓名,成績 as 數學 from Table_name where 科目='數學') aa2
on aa1.姓名=aa2.姓名) aa3
left join
(select 姓名,成績 as 英語 from Table_name where 科目='英語') aa4
on aa3.姓名=aa4.姓名 回復 更多評論
select 姓名,(case when 語文 then 成績) as 語文,(case when 數學 then 成績) as 數學,,(case when 英語 then 成績) as 英語 from table 回復 更多評論
只有注冊用戶登錄后才能發表評論。 | ||
![]() |
||
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
|
||
相關文章:
|
||