IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

query to extract first record


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prabhucs01
Warnings : 1

New User


Joined: 07 Mar 2005
Posts: 43

PostPosted: Thu Nov 24, 2005 8:22 pm
Reply with quote

can any give the query to extract the first record from a table.

thanks in advance
Back to top
View user's profile Send private message
tom_mat

New User


Joined: 13 Jul 2005
Posts: 11

PostPosted: Thu Nov 24, 2005 8:57 pm
Reply with quote

Hope this is what you meant!!!

SELECT EMPNO, LASTNAME, FIRSTNME, SALARY

FROM EMP

FETCH FIRST 1 ROWS ONLY;


Cheers!
Back to top
View user's profile Send private message
thiagold

New User


Joined: 29 Nov 2005
Posts: 3

PostPosted: Tue Nov 29, 2005 7:30 pm
Reply with quote

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
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Wed Nov 30, 2005 12:37 pm
Reply with quote

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
View user's profile Send private message
mk_kumar315

New User


Joined: 21 Nov 2005
Posts: 10

PostPosted: Thu Dec 01, 2005 5:38 pm
Reply with quote

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
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Thu Dec 01, 2005 5:47 pm
Reply with quote

hi frnd,
i think ROWNUM is in Oracle family not in DB2!!! Plz check it out.
Back to top
View user's profile Send private message
radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 435
Location: chennai, India

PostPosted: Thu Dec 01, 2005 7:04 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top