• <sub id="h4knl"><ol id="h4knl"></ol></sub>
    <sup id="h4knl"></sup>
      <sub id="h4knl"></sub>

      <sub id="h4knl"><ol id="h4knl"><em id="h4knl"></em></ol></sub><s id="h4knl"></s>
      1. <strong id="h4knl"></strong>

      2. Sql常見面試題

        時間:2024-10-24 23:28:58 NIIT認(rèn)證 我要投稿
        • 相關(guān)推薦

        2017年Sql常見面試題

          NIIT 在廣泛的軟件和硬件平臺上成功完成了1000多個主要的信息技術(shù)項目。以下是關(guān)于Sql常見面試題,希望大家認(rèn)真閱讀!

        2017年Sql常見面試題

          1. 用一條SQL 語句 查詢出每門課都大于80 分的學(xué)生姓名

          name kecheng fenshu

          張三 語文 81

          張三 數(shù)學(xué) 75

          李四 語文 76

          李四 數(shù)學(xué) 90

          王五 語文 81

          王五 數(shù)學(xué) 100

          王五 英語 90

          A: select distinct name from table where name not in (select distinct name from table where fenshu<=80)

          select name from table group by name having min(fenshu)>80

          2. 學(xué)生表 如下:

          自動編號 學(xué)號 姓名 課程編號 課程名稱 分?jǐn)?shù)

          1 2005001 張三 0001 數(shù)學(xué) 69

          2 2005002 李四 0001 數(shù)學(xué) 89

          3 2005001 張三 0001 數(shù)學(xué) 69

          刪除除了自動編號不同, 其他都相同的學(xué)生冗余信息

          A: delete tablename where 自動編號 not in(select min( 自動編號) from tablename group by 學(xué)號, 姓名, 課程編號, 課程名稱, 分?jǐn)?shù))

          3. 一個叫 team 的表,里面只有一個字段name, 一共有4 條紀(jì)錄,分別是a,b,c,d, 對應(yīng)四個球?qū)ΓF(xiàn)在四個球?qū)︖M(jìn)行比賽,用一條sql 語句顯示所有可能的比賽組合.

          你先按你自己的想法做一下,看結(jié)果有我的這個簡單嗎?

          答:select a.name, b.name

          from team a, team b

          where a.name < b.name

          4. 請用SQL 語句實現(xiàn):從TestDB 數(shù)據(jù)表中查詢出所有月份的發(fā)生額都比101 科目相應(yīng)月份的發(fā)生額高的科目。請注意:TestDB 中有很多科目,都有1 -12 月份的發(fā)生額。

          AccID :科目代碼,Occmonth :發(fā)生額月份,DebitOccur :發(fā)生額。

          數(shù)據(jù)庫名:JcyAudit ,數(shù)據(jù)集:Select * from TestDB

          答:select a.*

          from TestDB a

          ,(select Occmonth,max(DebitOccur) Debit101ccur from TestDB where AccID='101' group by Occmonth) b

          where a.Occmonth=b.Occmonth and a.DebitOccur>b.Debit101ccur

          5. 面試題:怎么把這樣一個表兒

          year month amount

          1991 1 1.1

          1991 2 1.2

          1991 3 1.3

          1991 4 1.4

          1992 1 2.1

          1992 2 2.2

          1992 3 2.3

          1992 4 2.4

          查成這樣一個結(jié)果

          year m1 m2 m3 m4

          1991 1.1 1.2 1.3 1.4

          1992 2.1 2.2 2.3 2.4

          答案一、

          select year,

          (select amount from aaa m where month=1 and m.year=aaa.year) as m1,

          (select amount from aaa m where month=2 and m.year=aaa.year) as m2,

          (select amount from aaa m where month=3 and m.year=aaa.year) as m3,

          (select amount from aaa m where month=4 and m.year=aaa.year) as m4

          from aaa group by year

          6. 說明:復(fù)制表( 只復(fù)制結(jié)構(gòu), 源表名:a 新表名:b)

          SQL: select * into b from a where 1<>1 (where1=1,拷貝表結(jié)構(gòu)和數(shù)據(jù)內(nèi)容)

          ORACLE:create table b

          As

          Select * from a where 1=2

          [<>(不等于)(SQL Server Compact)

          比較兩個表達(dá)式。 當(dāng)使用此運(yùn)算符比較非空表達(dá)式時,如果左操作數(shù)不等于右操作數(shù),則結(jié)果為 TRUE。 否則,結(jié)果為 FALSE。]

          7. 說明:拷貝表( 拷貝數(shù)據(jù), 源表名:a 目標(biāo)表名:b)

          SQL: insert into b(a, b, c) select d,e,f from a;

          8. 說明:顯示文章、提交人和最后回復(fù)時間

          SQL: select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b

          9. 說明:外連接查詢( 表名1 :a 表名2 :b)

          SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUTER JOIN b ON a.a = b.c

          ORACLE :select a.a, a.b, a.c, b.c, b.d, b.f from a ,b

          where a.a = b.c(+)

          10. 說明:日程安排提前五分鐘提醒

          SQL: select * from 日程安排 where datediff('minute',f 開始時間,getdate())>5

          11. 說明:兩張關(guān)聯(lián)表,刪除主表中已經(jīng)在副表中沒有的信息

          SQL:

          Delete from info where not exists (select * from infobz where info.infid=infobz.infid )

          12. 有兩個表A 和B ,均有key 和value 兩個字段,如果B 的key 在A 中也有,就把B 的value 換為A 中對應(yīng)的value

          這道題的SQL 語句怎么寫?

          update b set b.value=(select a.value from a where a.key=b.key) where b.id in(select b.id from b,a where b.key=a.key);

        《&.doc》
        将本文的Word文档下载到电脑,方便收藏和打印
        推荐度:
        点击下载文档

        【Sql常見面試題】相關(guān)文章:

        2017年java常見面試題及答案03-29

        SQL優(yōu)化大全03-08

        oracle的sql語句01-21

        2015年應(yīng)聘置業(yè)顧問常見的10道面試題03-19

        SQL語句的理解原則03-30

        SQL查詢語句大全04-25

        sql語句的各種模糊查詢03-30

        mysql SQL語句積累參考03-30

        執(zhí)行sql原理l分析03-30

        在线咨询
        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码
      3. <sub id="h4knl"><ol id="h4knl"></ol></sub>
        <sup id="h4knl"></sup>
          <sub id="h4knl"></sub>

          <sub id="h4knl"><ol id="h4knl"><em id="h4knl"></em></ol></sub><s id="h4knl"></s>
          1. <strong id="h4knl"></strong>

          2. 亚洲人成网站在线播放动漫 | 一区二区三区殴美在线播放 | 五十路熟中文字幕 | 在线好屌妞国产精品 | 伊人色综合久久天天人守人婷 | 五月婷婷精品视频在线播放 |

            2017年Sql常見面試題

              NIIT 在廣泛的軟件和硬件平臺上成功完成了1000多個主要的信息技術(shù)項目。以下是關(guān)于Sql常見面試題,希望大家認(rèn)真閱讀!

            2017年Sql常見面試題

              1. 用一條SQL 語句 查詢出每門課都大于80 分的學(xué)生姓名

              name kecheng fenshu

              張三 語文 81

              張三 數(shù)學(xué) 75

              李四 語文 76

              李四 數(shù)學(xué) 90

              王五 語文 81

              王五 數(shù)學(xué) 100

              王五 英語 90

              A: select distinct name from table where name not in (select distinct name from table where fenshu<=80)

              select name from table group by name having min(fenshu)>80

              2. 學(xué)生表 如下:

              自動編號 學(xué)號 姓名 課程編號 課程名稱 分?jǐn)?shù)

              1 2005001 張三 0001 數(shù)學(xué) 69

              2 2005002 李四 0001 數(shù)學(xué) 89

              3 2005001 張三 0001 數(shù)學(xué) 69

              刪除除了自動編號不同, 其他都相同的學(xué)生冗余信息

              A: delete tablename where 自動編號 not in(select min( 自動編號) from tablename group by 學(xué)號, 姓名, 課程編號, 課程名稱, 分?jǐn)?shù))

              3. 一個叫 team 的表,里面只有一個字段name, 一共有4 條紀(jì)錄,分別是a,b,c,d, 對應(yīng)四個球?qū)ΓF(xiàn)在四個球?qū)︖M(jìn)行比賽,用一條sql 語句顯示所有可能的比賽組合.

              你先按你自己的想法做一下,看結(jié)果有我的這個簡單嗎?

              答:select a.name, b.name

              from team a, team b

              where a.name < b.name

              4. 請用SQL 語句實現(xiàn):從TestDB 數(shù)據(jù)表中查詢出所有月份的發(fā)生額都比101 科目相應(yīng)月份的發(fā)生額高的科目。請注意:TestDB 中有很多科目,都有1 -12 月份的發(fā)生額。

              AccID :科目代碼,Occmonth :發(fā)生額月份,DebitOccur :發(fā)生額。

              數(shù)據(jù)庫名:JcyAudit ,數(shù)據(jù)集:Select * from TestDB

              答:select a.*

              from TestDB a

              ,(select Occmonth,max(DebitOccur) Debit101ccur from TestDB where AccID='101' group by Occmonth) b

              where a.Occmonth=b.Occmonth and a.DebitOccur>b.Debit101ccur

              5. 面試題:怎么把這樣一個表兒

              year month amount

              1991 1 1.1

              1991 2 1.2

              1991 3 1.3

              1991 4 1.4

              1992 1 2.1

              1992 2 2.2

              1992 3 2.3

              1992 4 2.4

              查成這樣一個結(jié)果

              year m1 m2 m3 m4

              1991 1.1 1.2 1.3 1.4

              1992 2.1 2.2 2.3 2.4

              答案一、

              select year,

              (select amount from aaa m where month=1 and m.year=aaa.year) as m1,

              (select amount from aaa m where month=2 and m.year=aaa.year) as m2,

              (select amount from aaa m where month=3 and m.year=aaa.year) as m3,

              (select amount from aaa m where month=4 and m.year=aaa.year) as m4

              from aaa group by year

              6. 說明:復(fù)制表( 只復(fù)制結(jié)構(gòu), 源表名:a 新表名:b)

              SQL: select * into b from a where 1<>1 (where1=1,拷貝表結(jié)構(gòu)和數(shù)據(jù)內(nèi)容)

              ORACLE:create table b

              As

              Select * from a where 1=2

              [<>(不等于)(SQL Server Compact)

              比較兩個表達(dá)式。 當(dāng)使用此運(yùn)算符比較非空表達(dá)式時,如果左操作數(shù)不等于右操作數(shù),則結(jié)果為 TRUE。 否則,結(jié)果為 FALSE。]

              7. 說明:拷貝表( 拷貝數(shù)據(jù), 源表名:a 目標(biāo)表名:b)

              SQL: insert into b(a, b, c) select d,e,f from a;

              8. 說明:顯示文章、提交人和最后回復(fù)時間

              SQL: select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b

              9. 說明:外連接查詢( 表名1 :a 表名2 :b)

              SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUTER JOIN b ON a.a = b.c

              ORACLE :select a.a, a.b, a.c, b.c, b.d, b.f from a ,b

              where a.a = b.c(+)

              10. 說明:日程安排提前五分鐘提醒

              SQL: select * from 日程安排 where datediff('minute',f 開始時間,getdate())>5

              11. 說明:兩張關(guān)聯(lián)表,刪除主表中已經(jīng)在副表中沒有的信息

              SQL:

              Delete from info where not exists (select * from infobz where info.infid=infobz.infid )

              12. 有兩個表A 和B ,均有key 和value 兩個字段,如果B 的key 在A 中也有,就把B 的value 換為A 中對應(yīng)的value

              這道題的SQL 語句怎么寫?

              update b set b.value=(select a.value from a where a.key=b.key) where b.id in(select b.id from b,a where b.key=a.key);