if there is a table with huge number of records and if i
want to extract only first 3 records from the table, what
query i have to provide to retreive first 3 records

Answer Posted / andank

SELECT * FROM <qualifier>.<table_name>
FETCH FIRST 3 ROWS ONLY
WITH UR;

The above query holds good, if you are thinking to fetch
rows in any specific order. Otherwise make use of "ORDER
BY".

If you want to filter the records bases on some condition
and fetch first 3 rows, make use of WHERE clause. For
example, if you want to see first 3 records of ACCOUNTS
department, use WHERE DEPTID ='Accounts' FETCH FIRST 3 ROWS
ONLY

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are catalog tables in db2?

814


What is ibm db2 connect?

773


How do I connect my db2 database to ibm?

818


What is db2 purescale?

785


What is the difference between spufi and qmf?

846


What is a db2 cursor?

830


Name the lockable units in DB2?

923


What is performance tuning db2?

864


Define buffer pool.

828


What is alias in db2?

821


List out the three types of page locks that can be held.

939


How can you find out the # of rows updated after an update statement?

886


Is it possible using max on a char column?

893


What is difference between alias and synonym in db2?

879


How to find the number of rows in a db2 table?

880