-1

I have a dataset like this:

year, average_price
1993, 222.2220,
1993, 2333.333
1993, 333.345
1994, 3445.444
1994, 4493.33
1995, 66005.33
1995, 33994.333
1995, 33993.333,
1996, 33884.33

I need to show average price per year in this dataset.

Does this mean I can do sum of average_prices and just do group by year, something like this?

select year as y, sum(average_price) as avg_price from table group by y

Thank you.

gogi
  • 9
  • 2
  • 1
    Hint: If you want the average price, use `AVG()`. – Gordon Linoff Feb 03 '21 at 18:45
  • Does this answer your question? [SQL query with avg and group by](https://stackoverflow.com/questions/10702546/sql-query-with-avg-and-group-by) – eshirvana Feb 03 '21 at 18:49
  • @GordonLinoff The average_price column is acutally average price value for that entry I just need to show all average prices per year. Do I need sum of all average prices for that year, than group them by the year. I hope this is clear to you, thank you. – gogi Feb 03 '21 at 18:58

1 Answers1

1

You could try something like this

select [year] as y, avg(average_price) as avg_price 
from Ttable 
group by [year];
SteveC
  • 5,955
  • 2
  • 11
  • 24