EXPERT RESPONSE
This is an interesting twist on
the usual "Top N" query question.
There are two parts to the answer.
First, you can get the last N
simply by running a Top N query
which includes an ORDER BY clause
with the DESCENDING keyword.
Second, since DB2 is one of the databases
which has implemented special syntax just
for the purpose of this type of query
(others being Microsoft SQL Server and Access with TOP
and MySQL and PostgreSQL with LIMIT),
you simply utilize that syntax.
According to the DB2 Universal Database for iSeries SQL Reference
page for the
select-statement, this would be
select foo, bar
from yourAS400table
order by foo descending
fetch first 100 rows only
For More Information
|