我在这里有一个游标声明:
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
子句会以这种方式与括号交互?