1

我的查询给了我以下错误信息:

 15:36:08  [SELECT - 0 row(s), 0.000 secs]  [Error Code: 102, SQL State: 37000]  [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'c'.

询问:

SELECT ftgnamn, ordernr, bestdat, q_text, oac, bcu, reminv, oldfak, reminv+oldfak
FROM
(
    (SELECT fr.ftgnamn, q_order.q_ordernr 'ordernr', q_order.kundbestdat 'bestdat', q_order.q_text, q_order.q_orderpos, 
            q_order.vbordsum 'oac', q_order.ordsum 'bcu', (q_order.vbordsum - q_order.vb_faktsum) 'reminv'
    FROM    fr, q_order, ac
    WHERE   fr.ftgnr=q_order.ftgnr AND q_order.vbordsum - q_order.vb_faktsum > 0
    ) a LEFT JOIN 
    (
    SELECT SUM(belaconto) 'oldfak', q_ordernr, q_orderpos
    FROM ac
    WHERE CAST('2000-05-31' AS DATETIME) <= ac.faktdat AND ac.faktdat IS NOT NULL
    GROUP BY q_ordernr, q_orderpos
    ) b ON (a.q_ordernr=b.q_ordernr AND a.q_orderpos=b.q_orderpos)
) c

谁能看到出了什么问题?

4

1 回答 1

2

让我为你分解一下。此示例返回完全相同的错误,因为您选择的是非子查询:

select 
    * 
from 
(
-- missing a select here!
-- select * from --uncomment this line
(
    select  1 as x
) a 
left join
(
    select 2 as y
) b
    on a.x=b.y
) c
于 2013-06-14T13:47:08.470 回答