我在这里有一个游标声明:
declare c cursor
for (select ProductName, ListPrice
from Products
where ListPrice > 700)
但是如果我添加order by
子句,我会收到错误:
declare c cursor
for (select ProductName, ListPrice
from Products
where ListPrice > 700
order by ListPrice desc)
错误:Incorrect syntax near the keyword 'order'.
但如果我拿走括号,错误就会消失:
declare c cursor
for select ProductName, ListPrice
from Products
where ListPrice > 700
order by ListPrice desc
也许我对SQL Server中括号的作用有点不清楚。是什么赋予了?为什么order by
子句会以这种方式与括号相互作用?
答案 0 :(得分:0)
order by
。将select
括在括号中会使SQL将其解释为子查询。