Q:

Using a Having clause with an outer join

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?

A:

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;

