sql server面试试题

时间:2024-09-02 06:48:34 面试笔试 我要投稿
  • 相关推荐

sql server面试试题


question:howcanilistnon-contignousdata?
indatabasepubs,icreateatabletestusingstatementasbelow,andiseveralrowasbelow

sql server面试试题


&nbsp程序代码
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?


&nbsp程序代码
missingaftermissingbefore
——————-———————
6&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp8
9&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp11


&nbsp



answer:
selectidfromtesttwherenotexists(select1fromtestwhereid=t.id+1)
ornotexists(select1fromtestwhereid=t.id-1)


question:howcanilistallbookwithpricesgreatherthantheaveragepriceofbooksofthesametype?
indatabasepubs,haveatablenamedtitles,itscolumnnamedpricemeanthepriceofthebook,andanothernamedtypemeanthetypeofbooks.
nowiwanttogettheresultasbelow:


&nbsp程序代码
type&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsptitle&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspprice&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
————————————————————————————————————————————————————————-
business&nbsp&nbsp&nbsp&nbspthebusyexecutive''sdatabaseguide&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp19.9900





answer:


&nbsp程序代码
selecta.type,a.title,a.pricefromtitlesa,
(selecttype,price=avg(price)fromtitlesgroupbytype)b
wherea.type=b.typeanda.price&gtb.price

【sql server面试试题】相关文章:

金蝶的SQL笔试题10-27

SQL Server开发人员应聘常见问题妙解10-07

面试的笔试题10-20

面试题精选?08-10

文员面试的试题!07-05

面试题精选07-11

网管面试题总结 面试题目分享08-10

面试试题早知道:华为面试题08-02

分享面试题目 教育职业面试题09-26

名企面试试题 面试题目 Google09-12