分组事件和发生地点。

huangapple go评论65阅读模式
英文:

Grouping incidents and where they happened

问题

如何编写一个查询来按年份、街区、主要类型、位置描述、区域和选区分组事件。

SELECT
  year, block, primary_type, location_description, district, ward
FROM `chicago_crime`
WHERE primary_type = "H******E"

我尝试了不同的函数,但我相信我漏掉了一些东西,但无法弄清楚。

英文:

How do I write a query to group incidents by year, block, primary_type,location_description, district, and ward.

SELECT
year, block, primary_type, location,_description, district,ward
FROM `chicago_crime`
WHERE primary_type = "H******E"

I've tied different functions and I believe I am missing something but can't figure it out.

答案1

得分: 1

你可以通过在WHERE子句之后使用GROUP BY子句来实现这一点。

SELECT
    year,
    block,
    primary_type,
    location_description,
    district,
    ward
FROM
    chicago_crime
WHERE
    primary_type = 'H******E'
GROUP BY
    year,
    block,
    primary_type,
    location_description,
    district,
    ward;
英文:

You can achieve that by using the GROUP BY clause, after WHERE clause.

SELECT
    year,
    block,
    primary_type,
    location_description,
    district,
    ward
FROM
    chicago_crime
WHERE
    primary_type = 'H******E'
GROUP BY
    year,
    block,
    primary_type,
    location_description,
    district,
    ward;

huangapple
  • 本文由 发表于 2023年6月16日 07:15:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76486044.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定