2016-11-28 127 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 –