How to select last line in a table without CURSOR in DB2

Cursors will be used in DB2 SQL PL stored procedures to perform a complex logic on a row-by-row basis. There are four basic SQL PL statements for working with cursors:
– the DECLARE CURSOR statement to define a cursor
– the OPEN statement to adjust the cursor
– the FETCH statement to retrieve the next row of the cursor
– the CLOSE statement to deactivate the cursor
we can find out last row using cursor with some logic but we can do it without cursor also by using following logic…
db2 “select * from schema_name.table_name order by column_name desc fetch first 1 rows only “

 
 

njoy the simplicity…….
©Victimizeit

DBMS/SQL

1)  OReilly.SQL.Cookbook download
2)  OReilly.Oracle.PL.SQL.Programming.4th.Edition download
3)  Oracle PLSQL Best Practices  download
4)  Good sql_for_beginners  download
5)  DB2-733-V9 download
6)  DB2 – Quick Beginings for Unix download
7)  IBM Informix Guide to SQL Tutorial  download
8)  OReilly-Oracle_Language_Pocket_Reference  download
9)  Mcgraw Hill – Database Management Systems. 2nd Ed.  download
10)  Oracle_9i_SQL_Reference  download
11)   Beginning.DB2.from.Novice.to.Professional. download
12)   IBM.Press.DB2.9.for.Linux.UNIX.and.Windows.6th.Edition.(731)download
13)   SQL Getting Started. download
14)   DB2CookBook download
15)   Understanding DB2 – Learning Visually with Examples download  ( thanks Rohit )