Search
Close this search box.

How do I do a SELECT TOP in SQL for DB2 on an iSeries (Power7) ?

This answer depends on what version of SQL you’re running. A FETCH clause will work for all. Here’s an example:

SELECT FLBILC, FLDATE, FLTCK #,
    FLCST #FROM PRDMETRO.FLHISTAF WHERE FLBILC =
        'CMD' ORDER BY FLBILC FETCH FIRST 10 ROW ONLY;


The equivalent in T-SQL would be:

SELECT TOP 10 FLBILC, FLDATE, FLTCK #,
    FLCST #FROM PRDMETRO.FLHISTAF WHERE FLBILC = 'CMD';

Print | posted on Wednesday, September 11, 2013 5:19 PM | Filed Under [ SQL DB2 ]

This article is part of the GWB Archives. Original Author: Ask Paula

Related Posts