Code: Alles auswählen.
SELECT * FROM tabelle_a AS a
LEFT OUTER JOIN tabelle_b AS b
ON a~docnr = b~docnr
INTO TABLE @DATA(lt_itab).
Code: Alles auswählen.
SELECT A~KEY, B~KEY, A~DOCNR, MAX( B~DATE )
FROM tabelle_a AS a
LEFT OUTER JOIN tabelle_b AS b
ON a~docnr EQ b~docnr
INTO TABLE @DATA(lt_itab)
GROUP BY A~KEY, B~KEY, A~DOCNR.
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
rob_abc
Code: Alles auswählen.
REPORT.
CLASS lcl_report DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
PRIVATE SECTION.
CLASS-METHODS select_with_delete.
CLASS-METHODS select_with_group.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD main.
select_with_delete( ).
select_with_group( ).
ENDMETHOD.
METHOD select_with_delete.
SELECT t1~pgmid, t1~object, t2~obj_name FROM tadir AS t1
LEFT OUTER JOIN tadir AS t2 ON t1~obj_name = t2~obj_name
WHERE t1~obj_name LIKE 'A%'
ORDER BY t1~pgmid, t1~object, t2~obj_name
INTO TABLE @DATA(t3)
BYPASSING BUFFER.
"cl_demo_output=>write( lines( t3 ) ).
DELETE ADJACENT DUPLICATES FROM t3 COMPARING pgmid object obj_name.
"cl_demo_output=>write( lines( t3 ) ).
ENDMETHOD.
METHOD select_with_group.
SELECT t1~pgmid, t1~object, t2~obj_name FROM tadir AS t1
LEFT OUTER JOIN tadir AS t2 ON t1~obj_name = t2~obj_name
WHERE t1~obj_name LIKE 'A%'
GROUP BY t1~pgmid, t1~object, t2~obj_name
INTO TABLE @DATA(t3).
"cl_demo_output=>write( lines( t3 ) ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
lcl_report=>main( ).
cl_demo_output=>display( ).
Folgende Benutzer bedankten sich beim Autor rob_abc für den Beitrag:
a-dead-trousers
Code: Alles auswählen.
WHERE date = ( SELECT max(date) FROM ... ).