gpt4 book ai didi

Mysql 受计数限制

转载 作者:行者123 更新时间:2023-11-29 02:49:38 28 4
gpt4 key购买 nike

我目前有一个查询,我正在将其放在一起以查找输入的次数。我试图找出如何将这些条目限制为低于特定计数(< 4)的任何内容。

SELECT
t.id `Ticket ID`,
a.asset `Asset`,
sol.solution `Solution reported`,
COUNT(tjou.id) `Journal entry count`

FROM tickets t
JOIN assets a ON t.asset_id = a.id
LEFT JOIN ticket_solutions tsol ON tsol.ticket_id = t.id
JOIN solutions sol ON tsol.solution_id = sol.id
JOIN ticket_journal tjou ON tjou.ticket_id = t.id
WHERE t.deleted IS FALSE
AND tjou.system_msg IS FALSE
AND DATE(t.close_dt) >= DATE_SUB(NOW(),INTERVAL 1 MONTH)
AND DATE(a.labor_w_end_dt) > CURDATE()
AND sol.solution != 'Communications Issue'
GROUP BY t.id
ORDER BY `Journal entry count` ASC

最佳答案

尝试追加这个

HAVING COUNT(tjou.id) < 4

GROUP BY 之后和 ORDER 语句之前

Reference.

关于Mysql 受计数限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37574412/

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