PARTITION BY and GROUP BY


#1

https://www.codecademy.com/courses/learn-sql/lessons/aggregate-functions/exercises/groupby?action=lesson_resume&link_content_target=interstitial_lesson

I had to calculate the number of items of each price. The one suggested was COUNT() and GROUP BY price. I thought COUNT() OVER(PARTITION BY price) should return a same result but it didn't. It is just getting a syntax error which I don't under stand why.



SELECT price, COUNT(*) OVER(PARTITION BY price) qty
FROM fake_apps;


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.