Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10671

Re: How to write a most repeating entry in a table?

$
0
0

Hi Usman,

 

If you want to make changes in your above query, you can make use of a intermediate internal table as given below:

 

        TABLES : SFLIGHT, SPFLI.

TYPES: BEGIN OF TY_WA,
        COUNT TYPE SY-INDEX,
        CITYFROM TYPE SPFLI-CITYFROM,
        END OF TY_WA.

DATA : COUNT LIKE SY-INDEX,
       WA_ROW TYPE TY_WA,
       it_row type table of ty_wa.

SELECT COUNT( * ) CITYFROM FROM SFLIGHT AS c INNER JOIN spfli AS d ON d~carrid = c~carrid
     AND d~connid = c~connid
     INTO WA_ROW
     GROUP BY D~cityfrom.
     WRITE / : WA_ROW-COUNT .
     WRITE  : WA_ROW-CITYFROM.
     append wa_row to it_row.
ENDSELECT.


SORT it_row BY COUNT DESCENDING.

READ table it_row INTO wa_row INDEX 1.

WRITE / :  'Max count: ' , WA_ROW-count.
WRITE   :  WA_ROW-CITYFROM.

Hope this suffice your requirement.

Reward points if helpful.

 

Thanks,

Barkha


Viewing all articles
Browse latest Browse all 10671

Trending Articles