1

I want to use a "having" clause with an outer join, using a column that is used in the outer join.

This is my query:

SELECT
  I.CARD_BIN BIN
FROM 
  GE_ICA_BIN I
LEFT OUTER JOIN GE_PAYEE_VALIDATION P ON I.CARD_BIN = P.CARD_BIN
LEFT OUTER JOIN GE_PAYEE PP ON PP.PAYEE_CODE = P.PAYEE_CODE
ORDER BY I.CARD_BIN
HAVING COUNT(*) > 1;

But this gives me this error:

ORA-00933: SQL command not properly ended
00933. 00000 -  "SQL command not properly ended"
*Cause:    
*Action:
Error at Line: 36 Column: 19

Line 36 is ORDER BY I.CARD_BIN.

Can someone tell me how I can solve this problem?

5

This is not my forte, but I am sure that you need a GROUP BY in there.

Also, out the ORDER BY line at the end of your statement. Something like this :

SELECT
  I.CARD_BIN BIN
FROM 
  GE_ICA_BIN I
LEFT OUTER JOIN GE_PAYEE_VALIDATION P ON I.CARD_BIN = P.CARD_BIN
LEFT OUTER JOIN GE_PAYEE PP ON PP.PAYEE_CODE = P.PAYEE_CODE
group by I.CARD_BIN
HAVING COUNT(*) > 1
ORDER BY I.CARD_BIN;
  • omg..... i forgot it. i see order by as group by, sorry mate, ur right. thanks for helping me T_T #feelsdizzy – DevYudh May 7 '13 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.