Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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;
share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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