Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Subquery

Former Member
0 Kudos

Hi All

I want to write a query that contains subquery , any clues on that ? ( for getting max value etc )

Thanks

Sandy

5 REPLIES 5

Former Member
0 Kudos

Hi Sandy,

Extract from the Sap help :


DATA: WA TYPE SFLIGHT. 

SELECT * FROM SFLIGHT 
    INTO WA 
    WHERE SEATSOCC = ( SELECT MAX( SEATSOCC ) FROM SFLIGHT ). 
  WRITE: / WA-CARRID, WA-CONNID, WA-FLDATE. 
ENDSELECT. 

Hope it helps,

Regards,

Erwan.

Former Member

Former Member
0 Kudos

Hi Sandy,

here is the example.

SELECT * FROM mara

INTO imara

WHERE matnr = ( SELECT max( matnr ) FROM mara ).

write:/1 imara-matnr.

ENDSELECT.

Also you can use EXISTS with some little variations

/Manik

0 Kudos

Hi Manik,

I don't really see in what way your post is different of mine...

Regards,

Erwan.

Former Member
0 Kudos

Hi Ewan,

It's the same, just the it was a time elapsed between your post and mine

cheers.

/Manik