案例模糊列SQL - Crystal Reports

时间:2014-10-28 22:12:37

标签: sql crystal-reports

我正在尝试清理一个有额外文字等的字段。我希望它们返回案例中的引用但如果它们没有这些条款,请使用DIR列代替。我得到的错误说它是模棱两可的。我不确定这意味着什么。

SELECT 
    L_Type, ALLE,
    CASE 
        WHEN ALLE LIKE '%F%'OR ALLE LIKE'%AS%' THEN 'EORCE'
        WHEN ALLE LIKE '%HOUR%'OR ALLE LIKE'%LE%' THEN 'U LEE'
        ELSE DIR
    END ALLEGCU
FROM  
    INC 
LEFT OUTER JOIN 
    AIO ON INC.INCNUM = AIO.INCNUM
LEFT OUTER JOIN 
    S ON INC.INCNUM = S.INCNUM
LEFT OUTER JOIN 
    OFC ON AIO.OFFNUM = OFC.OFFNUM
LEFT OUTER JOIN 
    ALLEG ON AIO.AIO_NUM = ALLEG.AIO_NUM
LEFT OUTER JOIN 
    DIR ON ALLEG.DIRNUM = DIR.DIRNUM
WHERE 
    LINK_TYPE = 'Of'
    AND (INC.RECEIVED_DT >= {ts '2009-01-01 00:00:00'} 
    AND INC.RECEIVED_DT < {ts '2014-06-30 00:00:01'})

1 个答案:

答案 0 :(得分:0)

您应该将表名添加到列中,如下所示:

select c.id, cc.name
from customer c
join customer_contact cc on c.id = cc.customer_id

通过添加表名或表别名,您将消除任何歧义。请务必将其添加到查询中的所有列。