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

Nested query from SQL - ABAP

Former Member
0 Likes
1,539

Hi,

Suppose I have a table with columns Id and Name, and I want to get

rows 6 to 10 (both inclusive) of that table, in sql I would write query

like

select top 5 Name, Id from (

select top 10 Name, Id from MyTable order by Id

) as student order by Id desc

Can anyone tell me how to write this nested query in ABAP ?

Thanks,

Srini.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
880

Hi,

Try this,

var1 = 6

var2 = 10

select * from table to itab.

delete itab where sy-tabix >var2 and sy-tabix < var1.

required data is in itab

6 REPLIES 6
Read only

Former Member
0 Likes
880

hi

I think u shd select all the data.

and moidfy ur internal table with sy-tabix.

Regards

Rasheed

Read only

0 Likes
880

Hi,

I want to do it in the query level itself.

Thanks,

Srini.

Read only

0 Likes
880

hi

I think in the query level u cant do u can select upto n rows. but u can take ranges for rows.

after selecting the data . loop to tht internal table and delete the records and modify tht internal table.

if u find the solution in query level u can post in SDn

Regards

rasheed

Read only

0 Likes
880

Hi,

I couldn't get the desired result in the form of nested queries.

But by reading n rows and deleting it using sy-tabix i got the solution. (Solution by Shwethali)

Thanks,

Srini.

Read only

Former Member
0 Likes
880

Hi

Please tell your requirement clearly,

if you are selecting the values from same table you dont need to write nested select queries.

if you are using more than one table better you go for FOR ALL ENTRIES or INNER JOINS

still if you want use aggregate functions like MAX COUNT etc

regards

Ramchander Rao.K

Read only

Former Member
0 Likes
881

Hi,

Try this,

var1 = 6

var2 = 10

select * from table to itab.

delete itab where sy-tabix >var2 and sy-tabix < var1.

required data is in itab