14

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?

Chris Snow
  • 23,813
  • 35
  • 144
  • 309

2 Answers2

36

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

SELECT * FROM customers FETCH FIRST 1 ROWS ONLY
Chris Snow
  • 23,813
  • 35
  • 144
  • 309
9

Another way on dashDB, and more easy for my opinion is to use the 'limit n', E.g.

SELECT * FROM customers LIMIT 1
AVP
  • 91
  • 1
  • 3