Tuesday, January 24, 2017

How to use Select Top N Rows from DB2 Database in AS400 System

it is quite simple if you want to limit the number of records return from the query execution in SQL Server

Select top N Rows from your table..

However DB2 did not support the select Top N Rows, there is a work around function

like this

Select * from your table order by column Desc fetch first N rows only

since the fetch first N rows only will return random number of rows. we must use order by column name to enforece the same records return by sorting the column.

No comments:

Post a Comment