gpt4 book ai didi

mysql - 在 SQL 中获取带有 COUNT 的行的名称

转载 作者:行者123 更新时间:2023-11-29 00:07:49 25 4
gpt4 key购买 nike

这是我当前的查询:

SELECT COUNT(`location`) AS 'amount' FROM offers GROUP BY location;

返回:

enter image description here

但是,我希望能够将每个数字归因于值。例如,它会输出:

enter image description here enter image description here

基本上,组

SELECT COUNT(`location`) AS 'amount' FROM offers GROUP BY location;

SELECT location FROM offers GROUP BY location;

进入一个查询

最佳答案

尝试:

SELECT location, COUNT(location) AS amount
FROM offers
GROUP BY location

关于mysql - 在 SQL 中获取带有 COUNT 的行的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26694167/

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