我已经尝试了多次但是出现了列模糊错误

时间:2018-01-27 12:13:42

标签: oracle10g

SELECT 
    V_CUSTSAL.DSTBID, V_CUSTSAL.DSTB, V_CUSTSAL.BATCH, 
    V_CUSTSAL.RATE, V_CUSTSAL.NRV, V_CUSTSAL.ACTUAL, 
    V_CUSTSAL.VACTUAL, V_CUSTSAL.BONUS, V_CUSTSAL.TEAMNAME,   
    V_CUSTSAL.GRP, V_CUSTSAL.PRD, V_CUSTSAL.VACTUALXDP, 
    V_CUSTSAL.NETVALUE, V_CUSTSAL.NETVALUEXDP, V_CUSTSAL.YEAR, V_CUSTSAL.YEARMONTH, 
    V_DAILYSTOCK.MONTH, V_DAILYSTOCK.DSTB, 
    V_DAILYSTOCK.NRV, V_DAILYSTOCK.PRD, V_DAILYSTOCK.STOCK, 
    V_DAILYSTOCK.VALUE, V_DAILYSTOCK.YEAR
FROM 
    SAS.V_CUSTSAL 
FULL OUTER JOIN 
    SAS.V_DAILYSTOCK ON (SAS.V_CUSTSAL.DSTBID = SAS.V_DAILYSTOCK.DSTBID);

1 个答案:

答案 0 :(得分:0)

您似乎正在对所有列名称进行限定,因此您不应该收到此错误。

使用表别名可能有助于解决问题:

SELECT c.DSTBID, c.DSTB, c.BATCH, c.RATE, c.NRV, c.ACTUAL,
       c.VACTUAL, c.BONUS, c.TEAMNAME, c.GRP, c.PRD, c.VACTUALXDP,
       c.NETVALUE, c.NETVALUEXDP, c.YEAR, c.YEARMONTH,
       d.MONTH, d.DSTB, d.NRV, d.PRD, d.STOCK, d.VALUE, d.YEAR
FROM SAS.V_CUSTSAL c FULL OUTER JOIN
     SAS.V_DAILYSTOCK d
     ON c.DSTBID = d.DSTBID;

请参阅。我想我看到了问题。 NRVYEAR出现两次。让我们给另一个别名:

SELECT c.DSTBID, c.DSTB, c.BATCH, c.RATE, c.NRV, c.ACTUAL,
       c.VACTUAL, c.BONUS, c.TEAMNAME, c.GRP, c.PRD, c.VACTUALXDP,
       c.NETVALUE, c.NETVALUEXDP, c.YEAR, c.YEARMONTH,
       d.MONTH, d.DSTB, d.NRV as ds_NRV, d.PRD, d.STOCK, s.VALUE,
       d.YEAR as ds.YEAR