开发者

SQL Syntax Issues

I can't for the life of me figure out what's wrong with this sql statement

select top(1) 
  OrderNumber 
 from (select top(5) 
         OrderNumb开发者_运维百科er 
       from SomeTable
       where TreePath='tests' 
       order by OrderNumber asc) 

Any Ideas?

Regards, Byron Cobb.


You need to alias the derived table

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜