Hi,
I have 3 tables :
Customers (a)
Product Categories (b)
Monthly Projections (c)
There can be more than one projection made for each category per month (for each customer).
Firstly, I would like to take the most recent monthly projection per category per customer. This can be done via a date field however how do I get the last monthly projection made for a category (for each customer)? NB I have tried using "Max (c.DateofProjection)" but I get all the projections made, not the latest in a given category (for a given customer).
Currently the query that is not working looks like :
SELECT a.CustomerName,b.CategoryName,c.MonthlyProjection, max(c.DateofProjection)
Secondly, I would like to total the monthly projections to reach an annual projection.
Is there an efficient way of doing this ?
Thanks in advance.
I have 3 tables :
Customers (a)
Product Categories (b)
Monthly Projections (c)
There can be more than one projection made for each category per month (for each customer).
Firstly, I would like to take the most recent monthly projection per category per customer. This can be done via a date field however how do I get the last monthly projection made for a category (for each customer)? NB I have tried using "Max (c.DateofProjection)" but I get all the projections made, not the latest in a given category (for a given customer).
Currently the query that is not working looks like :
SELECT a.CustomerName,b.CategoryName,c.MonthlyProjection, max(c.DateofProjection)
Secondly, I would like to total the monthly projections to reach an annual projection.
Is there an efficient way of doing this ?
Thanks in advance.