2016-11-28 125 views
0
if 1=(select oneTimePayClass from tblClass where [email protected]) 
    print 'True'; 
else 
    (select h.FeeHeadId,h.FeeHeadName,d.amount,d.FeeDefaultId 
    from tblFeeHead as h inner join tblFeeDefault as d on h.feeHeadId=d.feeHeadId 
    where [email protected] and [email protected] and [email protected] and [email protected] and [email protected] 
    order by h.orderNr); 

当我删除order by h.orderNr然后查询成功运行。SQL服务器查询显示错误语法错误附近的顺序

但是当我添加order by h.orderNr那就表明:近的顺序

错误不正确的语法

+1

从最终的SQL语句 –

回答

1

ORDER BY子句在视图,内联函数,派生表,子查询无效,公用表表达式。

做这样的

if 1=(select oneTimePayClass from tblClass where [email protected]) 
    print 'True'; 
else 
    select h.FeeHeadId,h.FeeHeadName,d.amount,d.FeeDefaultId 
    from tblFeeHead as h inner join tblFeeDefault as d on h.feeHeadId=d.feeHeadId 
    where [email protected] and [email protected] and [email protected] and [email protected] and [email protected] 
    order by h.orderNr; 
+0

中的括号去掉感谢ü非常BRO –