I am trying to run the following SQL query but BigQuery shows an error: PARTITION BY expression references column date which is neither grouped nor aggregated
SELECT
EXTRACT(MONTH FROM date) month,
country_name,
SUM(installs),
DENSE_RANK() OVER(PARTITION BY EXTRACT(MONTH FROM date) ORDER BY SUM(installs) DESC) as ranking
FROM `tableA`
WHERE EXTRACT(year FROM date) = 2022
GROUP BY month, country_name
ORDER BY month;
I tried to use Trunc, format_date functions but didn't work.