cancel
Showing results for 
Search instead for 
Did you mean: 

SQL statement: select maximal 20 rows of table

Former Member
0 Kudos

Hi everybody,

I know taht this is no dedidcated XI question.

But, does anybody the sql statement for selecting maximal (e.g. 20) rows?

Regards Mario

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

It depends from the database you are working with: for instance, with Oracle you have a specific syntax for the query:

select name from user where rownum < 10

you will get the first 10 entries only, thanks to the "rownum" embedded field.

Refere to here:

http://www.akadia.com/services/ora_important_part_3.html

Regards,

Sandro

Answers (3)

Answers (3)

Former Member
0 Kudos

Hay Mario,

As Sandro mentioned it all up to the DB you’re using, in DB2 its :

SELECT *

FROM URI.TB_GIRLS

FETCH FIRST 10 ROWS ONLY ;

And in MySQL it’s :

SELECT *

FROM tb_girls

ORDER BY age

LIMIT 10

And I can go on all night but I guess you got it

Uri.

udo_martens
Active Contributor
0 Kudos

Hi Mario,

u can use direct SQL Statement with

action= SQL_QUERY

Look to <a href="http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/frameset.htm">Document Formats for the Receiver JDBC Adapter</a>

Regards,

Udo

Former Member
0 Kudos

Hi,

Try this.

SELECT TOP <n> column1, column2, dt FROM <table>

Thanks,

Tuhin