- 相关推荐
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