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

Why do we need reorg in db2?

747


Mention the downsides of page level lock.

925


What is db2?

928


What does db2 stand for?

777


What is the function of logging in the db2 database?

864


What is a cursor in programming?

829


Where can you declare a cursor in a cobol-db2 program?

786


How many databases are there?

789


What are bind parameters in db2?

807


What is copy pending and check pending in db2?

758


Which command is used to remove all rows from a table?

787


Discuss about db2 bind?

871


what is diffrence b/w file-aid tool and file-aid utility???

4534


How can we retrieve the total number of records in RPG & CLLE?

385


What is difference between rollback and commit?

886