gpt4 book ai didi

mysql - 在同一张表的 Union 之后对两个值求和

转载 作者:行者123 更新时间:2023-12-01 00:17:30 25 4
gpt4 key购买 nike

这是我的查询:

SELECT location_description as Crimes,COUNT(*)
FROM test_sample
where test_sample.day_of_week LIKE"%sunday"
GROUP BY test_sample.location_description
UNION ALL
SELECT location_description as Crimes,COUNT(*)
FROM test_sample
where test_sample.day_of_week LIKE"%saturday"
GROUP BY test_sample.location_description

我的输出是: enter image description here

如何将这两个重复值合并为一个。

最佳答案

现在不需要UNION,只需调整WHERE以包含这两天;

SELECT location_description as Crimes,COUNT(*)
FROM test_sample
where test_sample.day_of_week LIKE"%sunday"
or test_sample.day_of_week LIKE"%saturday"
GROUP BY test_sample.location_description

关于mysql - 在同一张表的 Union 之后对两个值求和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52271515/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com