Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem with HANA SQL Join Query

Hi Experts,

I have a requirement to select all Business Partner from table BUT100 with Roles 'BUP001' and 'ZPREBP' ( join with table BUT100 ), as well I need the job function of the partner in table BUT000 (join with table BUT051 to get the field PAFKT - job function).

When I first join table BUT000 and BUT100 to get BP with roles 'BUP001' and 'ZPREBP', the number of records are 912218:

SELECT A.PARTNER, B.RLTYP

FROM SCHEMA.BUT000 A

INNER JOIN SCHEMA.BUT100 B ON A.PARTNER = B.PARTNER

WHERE B.RLTYP IN( 'BUP001', 'ZPREBP')

After that i join the above SQL with table BUT051 in order to get the field PAFKT - job function, the number of records become 914877

SELECT A.PARTNER, B.RLTYP, C.PAFKT

FROM SCHEMA.BUT000 A

INNER JOIN SCHEMA.BUT100 B ON A.PARTNER = B.PARTNER

LEFT   JOIN SCHEMA.BUT051 C ON A.PARTNER = C.PARTNER2

WHERE B.RLTYP IN( 'BUP001', 'ZPREBP')

The number of record from 1st SQL and 2nd SQL is not match. In the final result i was supposed to get only 912218 of records right?

Is the any mistake i made in the SQL script?

Regards,

Alexender

Former Member
Not what you were looking for? View more on this topic or Ask a question