A Boys Name or a Girl’s Name?
Reto Meier
191

Hi Reto, I was wondering how would you get the popularity ranking of a name? For example, what’s the ranking of name Emma among most popular female names of U.S. I wrote this query to fetch 100 most popular names and ranked them. However, when I add ‘where name = “Emma” it returns the ranking always as 1.

SELECT
 name,
 sum(number) as Popularity,
 dense_rank() over(partition by gender order by Popularity desc) AS rank
FROM
 [bigquery-public-data:usa_names.usa_1910_2013]
where gender = ‘F’ 
group by name, gender
order by Popularity desc
limit 100

Thank you!

Show your support

Clapping shows how much you appreciated Cansu Kaya’s story.