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

using order by statement !!

Amey-Mogare
Contributor
0 Likes
453

Hi,

I'm using following query in my RFC:-

SELECT *

FROM Transactions

UP TO 30 ROWS

WHERE TR_ID >= l_current_tid AND

PHASE = l_phase.

Now I want to ensure that this table Transactions is ordered by TR_ID before this query is executed..

How do I achieve this? Pls help me on this.

Awaiting for reply.

Regards,

Amey

3 REPLIES 3
Read only

Former Member
0 Likes
436

Hi

Hope it will help you,.

Pls reward if help.

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.

Read only

0 Likes
436

Thanks for quick reply..

But im using UP TO statement in query so what is happening is

1. it is first selecting all matched lines

2. Then ordering them by ORDER By condition

3. and then, returning 30 lines out of them..

So I want to sort the table first and then apply the select query..

I hope this better explains my problem..

Regards,

Amey

Read only

Former Member
0 Likes
436

Hi

1.SELECT the required rows from the database into ITAB without using ORDER BY

2. sort the ITAB

3. Fetch the required data from the ITAB

Note: If u use ORDER BY in SELECT , performance will go down

Narendra