Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

query to extract first record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: query to extract first record
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    Post subject: Re: query to extract first record
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    Post subject: Re: query to extract first record
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: 680
Location: NJ

PostPosted: Wed Nov 30, 2005 12:37 pm    Post subject: DB2 query
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    Post subject: Re: query to extract first record
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: 680
Location: NJ

PostPosted: Thu Dec 01, 2005 5:47 pm    Post subject: Fetch
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: 436
Location: chennai, India

PostPosted: Thu Dec 01, 2005 7:04 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us