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

Which component is responsible for db2 startup and shutdown?

637


Explain about dbrm.

618


What is meant by dclgen?

625


What is the maximum size of a char data type in db2?

594


What is image copy in db2?

580






Is ibm db2 open source?

595


What is the syntax for creating a table in the db2 database?

635


What is a page in db2?

620


How does cobol compile db2 program?

617


What is a db2 tablespace?

612


Are view updateable?

635


what are bind concepts in db2 cobol?

657


What is ibm db2 client?

530


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

669


What is the use of commit in db2?

640