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 union and union all?

625


How do I change the column size in db2?

709


Explain in detail about buffer manager and its functionalities?

661


What is release/acquire in bind?

733


What are concurrency issues?

708






What is db2 purescale?

644


What is db2?

820


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

796


What types of tables are there in the db2 database?

654


Which components manage deadlocks in db2?

704


What is the use of db2 optimizer?

694


What is the role of data manager in the db2 database?

727


How do I optimize a query in db2?

710


What is the difference between cursor and select statement?

714


What is package in cobol db2?

773