a week ago - last edited a week ago
Hi Experts,
I need your help with the OPEN SQL statements shared below. I'm comparing two SQL statements that use the same WHERE condition but have different numbers of columns. I expect both statements to return the same number of records since the WHERE condition is the same. However, when I execute the SQL statements, I find that the number of records returned is different. Can someone explain why this is happening?
SELECT plpo~plnty,
plpo~plnnr,
plpo~plnkn,
plpo~zaehl,
plpo~vgw01,
plpo~vgw02,
plpo~vgw03,
plpo~bmsch,
plpo~vornr,
plpo~vge01,
plpo~vge02,
plpo~vge03,
plpo~steus,
plas~loekz,
plas~plnfl,
plas~plnal,
crhd~arbpl,
crhd~objid
FROM plpo
INNER JOIN plas ON plpo~plnty = plas~plnty
AND plpo~plnnr = plas~plnnr
AND plpo~plnkn = plas~plnkn
AND plpo~zaehl = plas~zaehl
INNER JOIN crhd ON plpo~arbid = crhd~objid
FOR ALL ENTRIES IN @t_operazioni
WHERE plpo~plnty = @t_operazioni-plnty
AND plpo~plnnr = @t_operazioni-plnnr
AND plas~plnal = @t_operazioni-plnal
AND plpo~steus <> 'ZP00'
AND plas~loekz IS INITIAL
AND plas~plnfl = '000000'
INTO TABLE @DATA(t_plpo).
SELECT
plpo~vgw01,
plpo~vgw02,
plpo~vgw03,
plpo~bmsch,
plpo~vornr,
plpo~vge01,
plpo~vge02,
plpo~vge03,
crhd~arbpl
FROM plpo
INNER JOIN plas ON plpo~plnty = plas~plnty
AND plpo~plnnr = plas~plnnr
AND plpo~plnkn = plas~plnkn
AND plpo~zaehl = plas~zaehl
INNER JOIN crhd ON plpo~arbid = crhd~objid
FOR ALL ENTRIES IN @t_operazioni
WHERE plpo~plnty = @t_operazioni-plnty AND
plpo~plnnr = @t_operazioni-plnnr AND
plas~plnal = @t_operazioni-plnal AND
plpo~steus <> 'ZP00' AND
plas~loekz IS INITIAL AND
plas~plnfl = '000000'
INTO TABLE @DATA(t_plpo2).
Request clarification before answering.
Hi!
You have a "FOR ALL ENTRIES" construct in your SELECT statement and this has the effect that it only gives DISTINCT values back in the results. I don't know the tables involved in your statement but you may need to add whatever the key fields for PLPO are in the field list of your 2nd select to ensure that you get all the expected entries (even if you don't necessarily need the fields in the subsequent logic).
Hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
34 | |
21 | |
10 | |
8 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.