quary for
1> fetch last record
2> fetch in reverse order
3> fetch last 5 row
4> fetch second last record (their is no primary key)
i think concept of count can be use for this in 4th
Answer Posted / sarath
1) select id,name from tab1 order by id desc fetch first
row only
2) select id,name from tab1 order by id desc
3) select id,name from tab1 order by id desc fetch first 5
rows only
4) select id,count(*),name from tab1 order by id where count
(*) = (select count(*) from tab1)-1
| Is This Answer Correct ? | 6 Yes | 3 No |
Post New Answer View All Answers
What are the prerogatives?
What is the use of commit in db2?
Outputs of explain are with matchcols = 0. What does this signify?
What do you mean by between and in? Is between inclusive of specified range values?
Explain in brief how does db2 determine what lock-size to use?
What is a bind in db2?
What is bufferpool in db2?
Following a db2 update statement, what is the quickest way to compute the total number of updated rows?
How to fetch the last row from the table in SQL (db2)?
Suppose pgm A calling Pgm B .Pgm B has some Db2 program. at the time of compilation should plan and package will be created for both A and B or only B? What is the concept?
What is an instance in db2?
How can record locking be achieved in those DB2 versions which do not support it?
Where do you specify them?
by using cursors , we can access particular records from the table based on some condition, i want to delete those selected records, how can we write a query for this in the program?
in my project..TEST is db2 8.1 version In PROD it is 7.1 if i do REORG in TEST.. can I use the same REORG jcl with out modification in PROD region (this is DB2 8.1 )? if not, what modification i need to do in my REORG control card?