gpt4 book ai didi

Mysql - 双组依据

转载 作者:可可西里 更新时间:2023-11-01 07:52:39 25 4
gpt4 key购买 nike

我有以下查询:

SELECT DATE(created) AS con_date,
COUNT(*) AS con_per_day,
GROUP_CONCAT(word_id)
FROM connections
WHERE created > (NOW() - INTERVAL 30 DAY)
GROUP BY con_date

计算每天添加的字数。

enter image description here

一切都很好,但我想计算唯一数!注意 word_id 在最后一个原始文件中有 14,14。这必须算作 1。

我以为双 group_by 会削减它,但它似乎是一种错误的方式。

有什么想法吗?

最佳答案

使用distinct

    SELECT DATE(created) AS con_date,           COUNT(distinct word_id) AS con_per_day,           GROUP_CONCAT(word_id)    FROM connections    WHERE created > (NOW() - INTERVAL 30 DAY)    GROUP BY con_date

关于Mysql - 双组依据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20843306/

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