英文:
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;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论