Application Development and Automation 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: 
Read only

Subquery

Former Member
0 Likes
778

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
Read only

Former Member
0 Likes
616

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.

Read only

Former Member
Read only

Former Member
0 Likes
616

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

Read only

0 Likes
616

Hi Manik,

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

Regards,

Erwan.

Read only

Former Member
0 Likes
616

Hi Ewan,

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

cheers.

/Manik