对名称查询的查询支持

 收藏

根据8000s的频率查找前20个最不常见的人名。

是否有人会对其进行SQL查询/或答案?

这就是我所拥有的:

SELECT Distinct name as freq 
FROM human_names  
WHERE freq between 8000 and 8999     
ORDER BY freq DESC LIMIT 20;

但不返回结果。

回复
  • 我觉得您在寻找以下逻辑(BigQuery Standard SQL)

    SELECT name, COUNT(1) AS freq 
    FROM human_names  
    GROUP BY name
    HAVING freq between 8000 and 8999     
    ORDER BY freq DESC 
    LIMIT 20;