School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,481 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,768 people online right now. Registration is fast and FREE... Join Now!




Access 2000 SQL: Wild Query

 

Access 2000 SQL: Wild Query, Results Expected: Most Current Date from Dated Events based on Descrip

mohgeroth

12 Jun, 2009 - 06:03 PM
Post #1

New D.I.C Head
*

Joined: 25 Mar, 2009
Posts: 1

I'm trying to build a query (Without having to dump this into a ADODB recordset and process through VBA...)

I have four main Columns for the expected output (there are some others but those can be easily added) however I cannot see this query visually... the two important columns are...

M_Date is the date that this certain Item is going to go out
D_Date is the last day that M_Date was updated

Basically, this data changes on a WEEKLY basis... sometimes older M_Dates are not included because those dates have passed now...

I want to write a query that gives me the results for the MAX D_Date for EACH M_Date pairing (I only want the most recent changes for EACH mailing date because its the most updated figures)... This feels very multi-dimensional to me...

CODE

SELECT MAX(PH.D_Date), PH.M_Date, PH.Description, PH.Projected_Quantity
FROM P_History_t as PH
GROUP BY M_Date
HAVING MAX(D_Date)


Obviously this does not give me the results I wish and will not fire off due to using Grouping without aggregate functions on each coulmn, but I'm stumped with just seeing how this can be done... If I could only see a visual in a way that I could twist I could write this but I feel like I'm at the bottom of a well on this one... Group By Having comes to mind but Havn't played around too much in grouping but it feels like the way to go... any better approaches or should I stick with grouping and dive in a bit more?

*EDIT* Forgot to mention that, some of these M_Dates share multiple Dates with Other Items (Basically, Description of 'Item One' could have 3 different D_Dates but 'Item Two' could have only 2 D_Dates)... To make this even more complicated of course. Basically I need to know how to get to the: Highest D_Date for each M_Date for each Description where an M_Date can have Different Descriptions (Each one having its own record in this query)

This post has been edited by mohgeroth: 12 Jun, 2009 - 06:08 PM

User is offlineProfile CardPM
+Quote Post


tommyflint

RE: Access 2000 SQL: Wild Query

14 Jun, 2009 - 09:52 AM
Post #2

D.I.C Addict
Group Icon

Joined: 24 Jul, 2008
Posts: 584



Thanked: 28 times
My Contributions
It may help us if you could explain the structure of the table(s) your are trying to pull the data from as i cant really understand from what you have described smile.gif

tommyflint
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 03:59AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month