LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default subquery to keep maximum date

I have a table of project milestones with these fields:
milestone, date, cost, & project
"date" is the date the milestone was added or changed; so over
time a given milestone may have several entries which reflect changes in cost.
For example:
Milestone Date Cost Project
Build radio, 1 Jan 08, $100.00, Electronics
Build radio, 1 Mar 08, $110.00, Electronics
Build radio, 1 Apr 08, $90.00, Electronics

When my macro pulls the data, I want to only keep the Cost for the most
recent Date, i.e. Build radio, $90.00, Electronics

In Access I would use a sub-query, something like
SELECT ID, Milestone, Date, Cost, Project from Milestone_Table
Where (((ID) in (select top 1 ID
from Milestone_Table as dupe
where dupe.milestone = Milestone_Table.milestone
and dupe.project = Milestone_Table.project
and dupe.ID = Milestone_Table.ID
ORDER by dupe.date DESC, dupe.ID DESC)))
Order by Milestone_Table.Milestone, Milestone_Table.Project,
Milestone_Table.ID;

Is there a way I can do this directly in Excel so I don't have to export
data to Access, run subquery, port back into Excel?
--
Richard
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subquery Confusion Diana[_7_] Excel Programming 0 April 10th 07 05:32 PM
Sum with Parameters in a Subquery Diana[_7_] Excel Programming 5 April 10th 07 04:20 PM
Subquery after Left Join Pontificateur Excel Programming 1 January 19th 06 02:51 PM
Subquery dc Excel Worksheet Functions 7 June 3rd 05 01:36 PM


All times are GMT +1. The time now is 11:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"