Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 How to force a select query to abend neo4u DB2 5 Mon Apr 23, 2018 1:36 pm
No new posts VSAM - Accessing beyond record size Benchwarmer JCL & VSAM 6 Wed Apr 11, 2018 9:20 pm
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am
No new posts Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us