- 相關推薦
sql server面試試題
question:howcanilistnon-contignousdata?
indatabasepubs,icreateatabletestusingstatementasbelow,andiseveralrowasbelow
 程序代碼
createtabletest
(idintprimarykey)
go
intotestvalues(1)
intotestvalues(2)
intotestvalues(3)
intotestvalues(4)
intotestvalues(5)
intotestvalues(6)
intotestvalues(8)
intotestvalues(9)
intotestvalues(11)
intotestvalues(12)
intotestvalues(13)
intotestvalues(14)
intotestvalues(18)
intotestvalues(19)
go
nowiwanttolisttheresultofthenon-contignousrowasbelow,howcanidoit?
 程序代碼
missingaftermissingbefore
——————-———————
6            8
9            11
…
 
answer:
selectidfromtesttwherenotexists(select1fromtestwhereid=t.id+1)
ornotexists(select1fromtestwhereid=t.id-1)
question:howcanilistallbookwithpricesgreatherthantheaveragepriceofbooksofthesametype?
indatabasepubs,haveatablenamedtitles,itscolumnnamedpricemeanthepriceofthebook,andanothernamedtypemeanthetypeofbooks.
nowiwanttogettheresultasbelow:
 程序代碼
type        title                                                                           price                
————————————————————————————————————————————————————————-
business    thebusyexecutive''sdatabaseguide                                             19.9900
…
…
…
…
answer:
 程序代碼
selecta.type,a.title,a.pricefromtitlesa,
(selecttype,price=avg(price)fromtitlesgroupbytype)b
wherea.type=b.typeanda.price>b.price
【sql server面試試題】相關文章:
金蝶的SQL筆試題10-27
面試的筆試題10-20
面試題精選?08-10
文員面試的試題!07-05
面試題精選07-11
網管面試題總結 面試題目分享08-10
面試試題早知道:華為面試題08-02
分享面試題目 教育職業面試題09-26
名企面試試題 面試題目 Google09-12