Hello
I have 2 tables
TableStartPrice and TableNewPrice
In each 3 same fields: Adress, Date, Price
In TableStartPrice only one record per adress
In TableNewPrice could be several records per adress
With a query I want to know the last price (by date) for each adress coming from TableStartPrice
I could be the price from TableStartPrice if no new price in TabeNewPrice or the last new price from TableNewPrice
In my query I join both tables by adress field with including all records from TableStartPrice
If I do like this (Attached QueryLasTPrice0)
SELECT TableStartPrice.adress_start, Max(TableNewPrice.date_new) AS MaxOfDate, TableStartPrice.date_start
FROM TableNewPrice RIGHT JOIN TableStartPrice ON TableNewPrice.[adresse_new] = TableStartPrice.[adress_start]
GROUP BY TableStartPrice.adress_start, TableStartPrice.date_start;
It is not too bad, I get only 1 record from TableNewPrice even for adresses has 2 records in TableNewPrice
But also get date from TableStartPrice even if there is a new price with new date in TableNewPrice.
First question how to get the only the last date record from those 2 tables ?
After I had price column in my query like this (Attached QueryLasTPrice1)
SELECT TableStartPrice.adress_start, Max(TableNewPrice.date_new) AS MaxOfDate, TableNewPrice.price_new, TableStartPrice.date_start
FROM TableNewPrice RIGHT JOIN TableStartPrice ON TableNewPrice.[adresse_new] = TableStartPrice.[adress_start]
GROUP BY TableStartPrice.adress_start, TableNewPrice.price_new, TableStartPrice.date_start;
But now I have 2 lines results for an adress has 2 records in the TableNewPrice (388 Denver)
How to solve that ?
Thanks by advance for your help
Chris
I have 2 tables
TableStartPrice and TableNewPrice
In each 3 same fields: Adress, Date, Price
In TableStartPrice only one record per adress
In TableNewPrice could be several records per adress
With a query I want to know the last price (by date) for each adress coming from TableStartPrice
I could be the price from TableStartPrice if no new price in TabeNewPrice or the last new price from TableNewPrice
In my query I join both tables by adress field with including all records from TableStartPrice
If I do like this (Attached QueryLasTPrice0)
SELECT TableStartPrice.adress_start, Max(TableNewPrice.date_new) AS MaxOfDate, TableStartPrice.date_start
FROM TableNewPrice RIGHT JOIN TableStartPrice ON TableNewPrice.[adresse_new] = TableStartPrice.[adress_start]
GROUP BY TableStartPrice.adress_start, TableStartPrice.date_start;
It is not too bad, I get only 1 record from TableNewPrice even for adresses has 2 records in TableNewPrice
But also get date from TableStartPrice even if there is a new price with new date in TableNewPrice.
First question how to get the only the last date record from those 2 tables ?
After I had price column in my query like this (Attached QueryLasTPrice1)
SELECT TableStartPrice.adress_start, Max(TableNewPrice.date_new) AS MaxOfDate, TableNewPrice.price_new, TableStartPrice.date_start
FROM TableNewPrice RIGHT JOIN TableStartPrice ON TableNewPrice.[adresse_new] = TableStartPrice.[adress_start]
GROUP BY TableStartPrice.adress_start, TableNewPrice.price_new, TableStartPrice.date_start;
But now I have 2 lines results for an adress has 2 records in the TableNewPrice (388 Denver)
How to solve that ?
Thanks by advance for your help
Chris