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

how to take the back up of the DB2 table.

7 Answers  


database DSNDB01 means a.db2 catalog b.db2 directory c.BSDS d.active logs answer with reason please

1 Answers  


What is the difference between group by and order by?

2 Answers   IBM, TCS,


What is phantom read in db2?

0 Answers  


cobol-db2 runjcl please?

2 Answers   DELL,






What's the maximum number of volumes that can be added to a STOGROUP?

1 Answers   IBM,


How do you run JCL in cobol program

1 Answers   IBM, Syntel,


Usually, which is more important for DB2 system performance - CPU processing or I/O access?

1 Answers  


What is the syntax for FETCH in DB2 ?

0 Answers   MCN Solutions,


How to execute stored procedure in db2 command editor?

0 Answers  


Give the name of some fields form sqlca.

0 Answers  


What is the STOSPACE Utility used for?

1 Answers  


Categories