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
 

 

How 2 retrieve rows 4 latest updation?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Help-Me-Out

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Fri Jun 08, 2007 4:18 pm    Post subject: How 2 retrieve rows 4 latest updation?
Reply with quote

Hi,

I have the requirement to fetch the record for last updation.

I am not able to fetch the record. I have tried Max function. The table contains the duplicate rows. Can you anyone tell me how to fetch the records without writing a cursor?

Time_upd is field of the table.


Thanks,

Sandy...
Back to top
View user's profile Send private message

priyamnavada

New User


Joined: 24 Dec 2005
Posts: 52
Location: hyderabad

PostPosted: Fri Jun 08, 2007 4:36 pm    Post subject:
Reply with quote

SELECT MAX(TIME_UPD)
FROM TABLE
FETCH FIRST 1 ROW ONLY;
Back to top
View user's profile Send private message
priyamnavada

New User


Joined: 24 Dec 2005
Posts: 52
Location: hyderabad

PostPosted: Fri Jun 08, 2007 4:38 pm    Post subject:
Reply with quote

sorry... i was in rush. could not able to read your question correctly. what you want? you want the records lastly updated right?
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Fri Jun 08, 2007 4:52 pm    Post subject:
Reply with quote

If you have a timestamp in the table you can always use that timestamp to get the latest record updated.
Back to top
View user's profile Send private message
Help-Me-Out

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Fri Jun 08, 2007 7:18 pm    Post subject: Re: How 2 retrieve rows 4 latest updation?
Reply with quote

Thanks.

But yet my problem is not resolved.

MAX(TIME_UPD) will give me the unique row, but it creates the performance issue.

I need the record which is recently updated.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jun 08, 2007 7:33 pm    Post subject: Re: How 2 retrieve rows 4 latest updation?
Reply with quote

Help-Me-Out wrote:
Thanks.

But yet my problem is not resolved.

MAX(TIME_UPD) will give me the unique row, but it creates the performance issue.

I need the record which is recently updated.


Is time_upd an indexed column, if not that would be the cause of your performance issue.
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 To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
This topic is locked: you cannot edit posts or make replies. DB2 query Using Recursion, Converting... smilewithashu2 DB2 3 Tue Jan 03, 2017 12:50 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm


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