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

Answers were Sorted based on User's Feedback



if there is a table with huge number of records and if i want to extract only first 3 records from..

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

if there is a table with huge number of records and if i want to extract only first 3 records from..

Answer / gummadi

select * from table_name
order by ascending
fetch first 3 rows only

Is This Answer Correct ?    3 Yes 0 No

if there is a table with huge number of records and if i want to extract only first 3 records from..

Answer / hemachandar

select * from table_name
fetch first 3 rows only;

Is This Answer Correct ?    2 Yes 0 No

if there is a table with huge number of records and if i want to extract only first 3 records from..

Answer / viji

If there is any specific order they have to be fetched then use fetch first 3 records only.
Without order by, fetch first 3 records only will retrieve any 3 records in random order.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More DB2 Interview Questions

What is a thread?

3 Answers  


can I alter a table (e.g. adding a column) when other user is selecting some columns or updating some columns from the same table?

1 Answers  


One program calling 5 subprograms, its a cobol db2 program, after precompilation how many plans and packages will created?

3 Answers  


When do you use the IMAGECOPY?

4 Answers  


what is a collection?

2 Answers  






What is the purpose of the QUIESE Utility?

1 Answers  


What is -904 sql code? How to resolve it?

3 Answers  


Name the different types of Table spaces.

5 Answers   IBM,


is it possible to get -811 error when you use cursors. why?

2 Answers   IBM,


SQLCODE = -199, ERROR: ILLEGAL USE OF KEYWORD CHAR, TOKEN KEY was expected

0 Answers  


What do you mean by NOT NULL? When will you use it?

3 Answers  


What is a DBRM, PLAN ?

3 Answers  


Categories