Limiting query results in DB2

DB2 provides the FETCH FIRST command to limit query results.

select * from mytable fetch first 10 rows only;

To get the first 10 by column

select * from mytable order by id fetch first 10 rows only;

To get the last 10 by column

select * from mytable order by id desc fetch first 10 rows only;