我一生无法弄清楚此sql语句出了什么问题

select top(1)
  OrderNumber
 from (select top(5)
         OrderNumber
       from SomeTable
       where TreePath='tests'
       order by OrderNumber asc)


有任何想法吗?

问候,
拜伦·科布(Byron Cobb)。

最佳答案

您需要对派生表进行别名

select top 1
  myDerivedTable.OrderNumber
 from (select top 5
         OrderNumber
       from TABLE
       where TreePath='tests'
       order by OrderNumber asc) myDerivedTable
order by myDerivedTable.OrderNumber

关于sql - SQL语法问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3969851/

10-10 16:18