poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标。(欢迎大家咨询软件测试工程师就业培训,请加qq:908821478)

     下面的题目是神州数码的一位测试总监问过我的学员的面试题目,下面是题目的答案。

题目:

  写出一条Sql语句:

    取出表A中第31到第40记录(SQLServer, 以自动增长的ID作为主键,  注意:ID可能不是连续的。)

 

解答(已测试):

  1、假设ID是连续的:

    select top 10 * from A where ID not in (select top 30 ID from A)

  或

    select  *  from A where ID between 31 and 40

 

  2、假设ID是不连续的:

     select top 40 * from A except select top 30 * from A

  或

    select top 10 * from A where ID > (select max(ID) from A where ID in (select top 30 ID from A))

     或

    select top 10 * from A where ID not in (select top 30 ID from A) 

     poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标。(欢迎大家咨询软件测试工程师就业培训,请加qq:908821478)

     下面的题目是神州数码的一位测试总监问过我的学员的面试题目,下面是题目的答案。

题目:

  写出一条Sql语句:

    取出表A中第31到第40记录(SQLServer, 以自动增长的ID作为主键,  注意:ID可能不是连续的。)

 

解答(已测试):

  1、假设ID是连续的:

    select top 10 * from A where ID not in (select top 30 ID from A)

  或

    select  *  from A where ID between 31 and 40

 

  2、假设ID是不连续的:

     select top 40 * from A except select top 30 * from A

  或

    select top 10 * from A where ID > (select max(ID) from A where ID in (select top 30 ID from A))

     或

    select top 10 * from A where ID not in (select top 30 ID from A) 

相关文章:

  • 2021-07-15
  • 2022-12-23
  • 2021-10-28
  • 2021-12-02
  • 2021-07-09
  • 2021-10-18
  • 2021-09-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2022-12-23
  • 2021-11-04
  • 2021-07-06
相关资源
相似解决方案