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 explain in db2?

0 Answers  


What is the use of predicate?

0 Answers  


how to resolve -811 error. give clear explination

4 Answers   IBM,


I need to view the number of tables existing under one particular Owner. Is it possible? If so, pl give the SQL query for this?

0 Answers  


What if , we failed to mentioed null indicator in sql select query , that may retrieve null value ?

2 Answers   Cap Gemini,






what are the frequent DB2 abends did you encounter in your programs ?? What are different SQL abends ??

4 Answers   Xansa,


When reorg is used?

0 Answers  


What is collection in db2 bind?

0 Answers  


What is a clustered index?

1 Answers  


What is pagespace?

1 Answers  


How can you validate Sql errors during cursor operation in db2 pgms and where do you code?

0 Answers   IBM,


what is Runstats? Whem will u choose to runatats?

1 Answers   Danske,


Categories