I am a SQL beginner. I need some help in designing an effificent SQL query for the below use case.
Table 1:
1. Id
2. Cost
3. Price
4. Date
Table 2:
1. Week Id
2. Week start_date
3. Week end_date
Now I want to find the average cost and price for a given item id aggregated over a week along with the week's start date. Something like this
select a.id, avg(a.cost), avg(a.price), b.start_date
from table 1 a
......
Group by (a.id, b.week_id)