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 / sudipta

u may try this
assuming table 'tab1' has 2 fields id & name
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)

u try these & if any problem u may write

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of reorg in db2?

608


How can the firstname and the lastname from the emp table be concatenated to generate complete names?

748


What is lock escalation in db2?

574


What do you mean by rollback?

572


What are foreign keys in db2?

616






What is isolation level in db2?

577


What is universal database?

619


What do you mean by storage group (stogroup)?

583


What is ibm db2 database?

538


SET is the ANSI standard for variable assignment, SELECT is not. SET can only assign one variable at a time, SELECT can make multiple assignments at once. If assigning from a query, SET can only assign a scalar value. If the query returns multiple values/rows then SET will raise an error. SELECT will assign one of the values to the variable and hide the fact that multiple values were returned (so you'd likely never know why something was going wrong elsewhere - have fun troubleshooting that one) When assigning from a query if there is no value returned then SET will assign NULL, where SELECT will not make the assignment at all (so the variable will not be changed from it's previous value) As far as speed differences - there are no direct differences between SET and SELECT. However SELECT's ability to make multiple assignments in one shot does give it a slight speed advantage over SET.

2155


What is phantom read in db2?

640


What is db2 purescale?

551


If I have a view which is a join of two or more tables, can this view be updateable?

694


What is the difference between "db2ilist" and "db2 get instance" commands in DB2 Database Server?

714


For a db2 column that is being defined as decimal (11, 2), discuss the cobol picture clause.

660