<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          幾道常見的SQL面試題

          共 3441字,需瀏覽 7分鐘

           ·

          2021-04-10 10:38

          點(diǎn)擊關(guān)注上方“SQL數(shù)據(jù)庫開發(fā)”,

          設(shè)為“置頂或星標(biāo)”,第一時(shí)間送達(dá)干貨

          SQL專欄

          SQL基礎(chǔ)知識第二版
          SQL高級知識第二版


          收集了幾道比較常見的SQL面試題,在不看底部參考答案的情況下,看自己能做對幾道。

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

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

          3.一個叫 team 的表,里面只有一個字段name, 一共有4 條紀(jì)錄,分別是a,b,c,d, 對應(yīng)四個球?qū)?,現(xiàn)在四個球?qū)M(jìn)行比賽,用一條sql  語句顯示所有可能的比賽組合.
          你先按你自己的想法做一下,看結(jié)果有我的這個簡單嗎?

          4.請用SQL  語句實(shí)現(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

          5.面試題:怎么把這樣一個表兒
          查成這樣一個結(jié)果

          6. 說明:復(fù)制表( 只復(fù)制結(jié)構(gòu), 源表名:a新表名:b)
           
          7.  說明:拷貝表( 拷貝數(shù)據(jù), 源表名:a目標(biāo)表名:b)

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

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

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

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

          12.有兩個表A 和B ,均有key 和value 兩個字段,如果B 的key 在A 中也有,就把B 的value 換為A 中對應(yīng)的value
          這道題的SQL 語句怎么寫?


          參考答案

          1、

          --方法一:
          select distinct name 
          from table 
          where name not in (
          select distinct name f
          rom table where fenshu<=80
          )
          --方法二:
          select name from table 
          group by name 
          having min(fenshu)>80


          2、

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


          3、

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


          4、

          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、

          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、

          --SQL:
          select * into b from a where 1<>1

          --ORACLE:
          create table b
          As
          Select * from a where 1=2

           注:<>(不等于)(SQL Server Compact)

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


          7、

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


          8、

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


          9、

          --SQL Server:
          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 Server
          select * from 日程安排
          where datediff('minute',開始時(shí)間,getdate())>5


          11、

          --SQL Server:
          Delete from info
          where not exists (
          select * from infobz
          where info.infid=infobz.infid
          )


          12、

          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);



          最后給大家分享我寫的SQL兩件套:《SQL基礎(chǔ)知識第二版》《SQL高級知識第二版》的PDF電子版。里面有各個語法的解釋、大量的實(shí)例講解和批注等等,非常通俗易懂,方便大家跟著一起來實(shí)操。


          有需要的讀者可以下載學(xué)習(xí),在下面的公眾號「數(shù)據(jù)前線」(非本號)后臺回復(fù)關(guān)鍵字:SQL,就行

          數(shù)據(jù)前線


          后臺回復(fù)關(guān)鍵字:1024,獲取一份精心整理的技術(shù)干貨

          后臺回復(fù)關(guān)鍵字:進(jìn)群,帶你進(jìn)入高手如云的交流群

          記得幫忙點(diǎn)「」和「在看」↓

          謝謝啦

          瀏覽 67
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  国产一区操逼视频 | 日本一三高清 | 青青草人人操人人摸人人干 | 67194亚洲 | 国产偷抇久久精品A片69探花 |