Restricting Data to the Most recent Month

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please help me!! I need to restrict the data in my query to isolate pricing to the most rescent month.
Before
Month Customer Pric
2003P10 A $19.0
2003P9 A $18.
2003P7 B $20.
2003P8 B $16.

After
Customer Pric
A $19.0 (most recent price
B $16.0 (most recent price

Thanks
 
Your situation is made more complicated because you're storing multiple data
in the Month (note: Not good practice to use Month, Year, Date, Day, Time,
Name, etc. as the names of fields, because these are reserved words / names
of VBA functions in ACCESS, and you can greatly confuse ACCESS when you use
them, which at best can provide erroneous data and at worst make your query,
form, report, or database stop working correctly) field. Why not store the
year in one field and the month in a second field? Then you can very easily
do what you seek by finding the Maximum of both fields.

However, with your setup, something such as this query might do the trick:

SELECT Customer, Price FROM TableName
WHERE Val(Mid([Month], 6)) =
(SELECT Max(Val(Mid(T.[Month]))) FROM TableName AS T
WHERE T.Customer = TableName.Customer)
ORDER By Customer;



--
Ken Snell
<MS ACCESS MVP>



tjberrym said:
Please help me!! I need to restrict the data in my query to isolate
pricing to the most rescent month.
 
Back
Top