Shall i use this query to retrieve first 4 records,

Select empno, sal from emptbl where empno < 5. like this can
we fetch first 100 records?

Answers were Sorted based on User's Feedback



Shall i use this query to retrieve first 4 records, Select empno, sal from emptbl where empno <..

Answer / madhu t

if empno is a primary key then the records in table are
stored in ascending order of empno. hence we can use empno
< 5 to fetch the first 4 records of table.
There is also a standar query to fetch the first 10/100/200
records as below...
select empno,sal from emptble fetch first 100 rows only;

Is This Answer Correct ?    9 Yes 0 No

Shall i use this query to retrieve first 4 records, Select empno, sal from emptbl where empno <..

Answer / mr. cooooool

Hi.............

No. you cann't use this.
this query will display records less than 5.
not to for first 4 records.

For exm.
Suppose i have duplicate records like
Empno
1
2
1
1
3
4
then it display all the above records.
b'coz these all r less than 5.


Thanks.

Is This Answer Correct ?    9 Yes 1 No

Shall i use this query to retrieve first 4 records, Select empno, sal from emptbl where empno <..

Answer / anju

I dont think records are stored in the sorted order of primary key in DB2. It happens only in VSAM!

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More DB2 Interview Questions

How do I handle -911 (deadlock) error in a db2 program so that the program will never abend?

3 Answers   CTS, IBM,


Explain what a plan is?

3 Answers   CTS,


What does it mean if the null indicator has -1, 0, -2?

1 Answers  


Select empno, sal from emptbl where empno < 101.By this query can we fetch first 100 recs? where empno is primary key.It won't throw -811 error? if it wont,then what is use of cursor technique while fetching first 100 recs. Please need more clarification.

2 Answers  


What are db2 tables?

0 Answers  






Explain about rct in db2?

0 Answers  


Hi i need to write a query on the following requirement. SELECT COMM_TEXT INTO :WS_MIKM_COMM_TEXT FROM MPIPROD.MIKMV01 WHERE ACCOUNT_NO = :WFD_ACCOUNT_NO AND (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT AND SUBSTR(COMM_TEXT,47,14) = :WS_DENY_DESC) OR (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT) The above query is to be modified. The requirement is if both the fields are equal then that has to be given priority. In the above query if it satisfies any one it comes out without checking if both being equal is possible.

1 Answers  


What is a bind card?

0 Answers  


what is the steps followed in EXPLAIN Process or EXPLAIN command. (Explain is for identifying the optimized access path but how or what is the steps for doing the EXPLAIN)

4 Answers   IBM,


what are the max. & min. no. of partitions allowed in a partition tablespace?

2 Answers   IBM,


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

0 Answers  


What is a dbrm in db2?

0 Answers  


Categories