Search code examples
dashdb

how to perform 'SELECT TOP X FROM TABLE' type queries with DB2 / dashDB


I would like to perform the equivalent of SELECT TOP 1 ... query in db2 / dashDB:

 SELECT TOP 1 * FROM customers

How can I achieve this?


Solution

  • You can achieve this query using the FETCH FIRST x ROWS ONLY statement, E.g.

    SELECT * FROM customers FETCH FIRST 1 ROWS ONLY