View previous topic :: View next topic
|
Author |
Message |
prabhucs01 Warnings : 1 New User
Joined: 07 Mar 2005 Posts: 43
|
|
|
|
can any give the query to extract the first record from a table.
thanks in advance |
|
Back to top |
|
|
tom_mat
New User
Joined: 13 Jul 2005 Posts: 11
|
|
|
|
Hope this is what you meant!!!
SELECT EMPNO, LASTNAME, FIRSTNME, SALARY
FROM EMP
FETCH FIRST 1 ROWS ONLY;
Cheers! |
|
Back to top |
|
|
thiagold
New User
Joined: 29 Nov 2005 Posts: 3
|
|
|
|
tom_mat wrote: |
Hope this is what you meant!!!
SELECT EMPNO, LASTNAME, FIRSTNME, SALARY
FROM EMP
FETCH FIRST 1 ROWS ONLY;
Cheers! |
I'm working with DB2 V6, and my version doesn't support the "fetch first N rows only" statamente (only at V7 or +).
How may I do the request in DB2 V6 version? |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
hi frnd,
i think u can use the primary key...
ie.,
Quote: |
select * from emp where empno='E01'; |
this is the way i think so since u r using V6 |
|
Back to top |
|
|
mk_kumar315
New User
Joined: 21 Nov 2005 Posts: 10
|
|
|
|
SELECT EMPNO, LASTNAME, FIRSTNME, SALARY
FROM EMP
WHERE ROWNUM = 1;
I hope this will solve your problem.Please check it.And if any wrong , then let us to know.
Bye,
Kumar. |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
hi frnd,
i think ROWNUM is in Oracle family not in DB2!!! Plz check it out. |
|
Back to top |
|
|
radhakrishnan82
Active User
Joined: 31 Mar 2005 Posts: 435 Location: chennai, India
|
|
|
|
Do you have date-timestamp in your table?
If yes,then you can fetch first record from the table.It will be very similar to fetch maximum salary from a table.
or by using any unique key in that table can give the result.
hope this helps. |
|
Back to top |
|
|
|