‎2008 Mar 31 7:20 AM
Hi,
Can anyone give me the difference between SORT and ORDER BY?
Thanks!!
‎2008 Mar 31 7:35 AM
Hi,
You can sort a standard or hashed table in a program. To sort a table by its key, use the statement
SORT ASCENDING .
The statement sorts the internal table ASCENDING
BY ASCENDING
...
The table is now sorted by the specified components ASCENDING
ASCENDING ...
The lines are sorted by the columns .....
Example
DATA: BEGIN OF WA,
CARRID TYPE SFLIGHT-CARRID,
CONNID TYPE SFLIGHT-CONNID,
MIN TYPE I,
END OF WA.
SELECT CARRID CONNID MIN( SEATSOCC ) AS MIN
INTO CORRESPONDING FIELDS OF WA
FROM SFLIGHT
GROUP BY CARRID CONNID
ORDER BY CARRID MIN DESCENDING.
WRITE: / WA-CARRID, WA-CONNID, WA-MIN.
ENDSELECT.
The output is as follows:
The lines of the database table SFLIGHT are grouped according to the columns CARRID and CONNID, and the system finds the minimum value of the column SEATSOCC for each group. The selection is sorted by CARRID in ascending order and by the minimum value of SEATSOCC in descending order, using the alias name MIN for the aggregate expression.
with regards,
sowjanya
‎2008 Mar 31 7:22 AM
Hi,
SORT is used to sort internal tables in abap programs
order by is used in select query to retrieve data form database tables
by ascending or descending
Regards,
V.Balaji
Reward if Usefull...
‎2008 Mar 31 7:35 AM
Hi,
You can sort a standard or hashed table in a program. To sort a table by its key, use the statement
SORT ASCENDING .
The statement sorts the internal table ASCENDING
BY ASCENDING
...
The table is now sorted by the specified components ASCENDING
ASCENDING ...
The lines are sorted by the columns .....
Example
DATA: BEGIN OF WA,
CARRID TYPE SFLIGHT-CARRID,
CONNID TYPE SFLIGHT-CONNID,
MIN TYPE I,
END OF WA.
SELECT CARRID CONNID MIN( SEATSOCC ) AS MIN
INTO CORRESPONDING FIELDS OF WA
FROM SFLIGHT
GROUP BY CARRID CONNID
ORDER BY CARRID MIN DESCENDING.
WRITE: / WA-CARRID, WA-CONNID, WA-MIN.
ENDSELECT.
The output is as follows:
The lines of the database table SFLIGHT are grouped according to the columns CARRID and CONNID, and the system finds the minimum value of the column SEATSOCC for each group. The selection is sorted by CARRID in ascending order and by the minimum value of SEATSOCC in descending order, using the alias name MIN for the aggregate expression.
with regards,
sowjanya