国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

面試題整理:SQL(一)

2024-07-21 02:46:12
字體:
來源:轉載
供稿:網友
面試題整理:SQL(一)

1.橫縱表轉換

A表

Name

Course

Grade

Alex

English

80

Alex

Chinese

70

Alex

Japanese

85

Bob

English

75

Bob

Chinese

85

Bob

Japanese

80

B表

Name

English

Chinese

Japanese

Alex

80

70

85

Bob

75

85

80

Chris

90

70

60

A -> B

select Name, SUM(case Course when 'English' then Grade else 0 end) as English,SUM(case Course when 'Chinese' then Grade else 0 end) as Chinese,SUM(case Course when 'Japanese' then Grade else 0 end) as Japanesefrom TranscriptAgroup by Name

B -> A

select Name,'English' AS Course,English  AS Grade from TranscriptBunion all select Name,'Chinese' AS Course,Chinese AS Grade from TranscriptB union all select Name,'Japanese' AS Course,Japanese AS Grade from TranscriptBorder by Name,Course desc;

2.假設有學習成績表

用一條SQL查出每一門成績都大于80的學生的姓名

select distinct name from table where name not in (select distinct name from table where chengji <= 80)select name from table group by name having min(chengji)>80

3.假設有Team表,只有一個Name字段,代表球隊名字

用SQL查處各隊之間互相比賽的組合

select a.name, b.name from team a, team b where a.name< b.name

4.統計工資累加

A表

Year

Salary
2010

1000

2011 

1500
2012

2000

2013

2500

B表

Year

Salary
2010

1000

2011 

2500
2012

4500

2013

7000

A -> B

select b.Year, sum(a.Salary) AccSalary from TA a, TA bwhere a.Year <= b.Yeargroup by b.Yearselect a.year, (select sum(b.Salary) from TA b where b.Year <= a.year) AccSalary from TA a

To be continue...


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 铜川市| 额济纳旗| 三门峡市| 高淳县| 通州区| 甘孜县| 锡林郭勒盟| 中牟县| 上虞市| 望奎县| 铜山县| 乾安县| 开阳县| 历史| 彭水| 密山市| 兴仁县| 苏州市| 曲周县| 阳江市| 左权县| 久治县| 建湖县| 丹巴县| 南部县| 延安市| 酉阳| 东丽区| 太仆寺旗| 永城市| 瑞安市| 张家川| 广昌县| 平果县| 绥化市| 衡阳县| 本溪市| 松潘县| 城市| 吉木萨尔县| 梅州市|