需要从exists子句中的表中获取列

时间:2014-11-19 16:46:43

标签: sql oracle

我的查询如下:

SELECT AIDI.LOAN_NUM, AIDI.LOCATION_CODE, AIDI.ORD_NUM, AIDI.MTN, AIDI.LOAN_STATUS, COUNT(*)
    FROM table1 AIDI
    WHERE AIDI.LOAN_STATUS = 'A'
    AND EXISTS (SELECT 1 FROM ORDERS AO
        WHERE AO.ACE_ORD_NUM = AIDI.ORD_NUM
        AND AO.ACE_ORD_COMPLETION_TIME >= TRUNC(SYSDATE -1)
        AND AO.ACE_ORD_COMPLETION_TIME < TRUNC(SYSDATE))
    GROUP BY AIDI.LOAN_NUM, AIDI.LOCATION_CODE, AIDI.ORD_NUM,         AIDI.MTN, AIDI.LOAN_STATUS
    HAVING COUNT(*) > 1;

我需要将AO.ACE_ORD_COMPLETION_TIME这一列放入select子句中,这样我才能在结果集中看到日期。

0 个答案:

没有答案