gpt4 book ai didi

php - 找到没有: fields that have appeared twice or more in a table

转载 作者:行者123 更新时间:2023-11-29 06:05:56 25 4
gpt4 key购买 nike

我有一个表data,其中列名称为number、start、end

我现在需要选择出现两次或多次的数字(number 列的字段),然后计算它们出现的次数。

有什么简单的方法可以做到这一点吗?

示例:-number--------开始--------结束----

      191            x          x
123 x x
45 x x
191 x x
37 x x
191 x x
45 x x

所以现在结果应该是:2(191 和 45 - 都重复两次或更多次)

最佳答案

SELECT `number`, COUNT(`number`) AS count
FROM `data`
GROUP BY `number`
HAVING COUNT(`number`) > 1
ORDER BY COUNT(`number`) DESC;

对于给定的一组输入值,输出应为:

------------------
| number | count |
------------------
| 191 | 3 |
------------------
| 45 | 2 |
------------------

关于php - 找到没有: fields that have appeared twice or more in a table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11507348/

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