oracle

时间:2015-07-09 04:41:32

标签: oracle

        select  wi.MOBILE,hb.TXN_TYPE
        from pbxhbl.WORK_ITEMS wi inner join
        pbxhbl.HBL_TRANSACTIONS hb
        on wi.MOBILE=hb.PAYER_MSVA or wi.MOBILE=hb.PAYEE_MSVA
        where wi.SOURCE_MODULE=2 or wi.SOURCE_MODULE=15 and wi.status=1 and wi.MOBILE 
        select  wi.MOBILE,hb.TXN_TYPE
        group by wi.mobile having count(hb.ID_USE_CASE)=1
        order by wi.MOBILE

这是我的查询,当我将查询更改为

时,它给出的错误不是group by子句
        select  wi.MOBILE,hb.TXN_TYPE
        from pbxhbl.WORK_ITEMS wi inner join
        pbxhbl.HBL_TRANSACTIONS hb
        on wi.MOBILE=hb.PAYER_MSVA or wi.MOBILE=hb.PAYEE_MSVA
        where wi.SOURCE_MODULE=2 or wi.SOURCE_MODULE=15 and wi.status=1 and wi.MOBILE 
        select  wi.MOBILE,hb.TXN_TYPE
        group by wi.mobile,hb.TXN_TYPE having count(hb.ID_USE_CASE)=1
        order by wi.MOBILE

现在每件事情都是对的,但问题是现在我正在获得重复记录,我该如何解决这个问题

1 个答案:

答案 0 :(得分:0)

检查此查询是否有效

SELECT DISTINCT WI.MOBILE, HB.TXN_TYPE
  FROM PBXHBL.WORK_ITEMS WI
 INNER JOIN PBXHBL.HBL_TRANSACTIONS HB
    ON WI.MOBILE = HB.PAYER_MSVA
    OR WI.MOBILE = HB.PAYEE_MSVA
 WHERE WI.SOURCE_MODULE = 2
    OR WI.SOURCE_MODULE = 15
   AND WI.STATUS = 1
 GROUP BY WI.MOBILE, HB.TXN_TYPE
HAVING COUNT(HB.ID_USE_CASE) = 1
 ORDER BY WI.MOBILE