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 select record x+7 or x+2 based... JoAnn Kulcyk SYNCSORT 6 Tue Jan 16, 2018 10:49 pm
No new posts reg query on DYNALLOC feature raghuraman123 SYNCSORT 12 Wed Jan 10, 2018 2:42 pm
No new posts query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm
No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm

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