gpt4 book ai didi

jquery - MySql Count(sno) 按日期显示旧记录

转载 作者:太空宇宙 更新时间:2023-11-03 10:41:17 28 4
gpt4 key购买 nike

我有下表:

enter image description here

 SELECT 
COUNT(h.sno) AS total
FROM
receipt_mov_history h,
receipt r
WHERE h.rec_sno = r.sno
AND h.assigned_to = 6
AND h.is_completed = 0
AND h.completed_by = 0
AND h.assigned_on <= DATE_SUB(h.assigned_on, INTERVAL 15 DAY)
ORDER BY h.sno DESC

我正在运行上述查询以获取所有具有 assigned_to = 6 且早于或等于 15 天(早于 15 天的记录)的记录。在快照表中,您可以看到只有一行超过 15 天(突出显示)。但是上面的查询在结果中返回了 2。

我的查询有什么问题?

最佳答案

SELECT 
COUNT(h.sno) AS total
FROM
receipt_mov_history h,
receipt r
WHERE h.rec_sno = r.sno
AND h.assigned_to = 6
AND h.is_completed = 0
AND h.completed_by = 0
AND h.assigned_on <= DATE_SUB(now(), INTERVAL 15 DAY)
ORDER BY h.sno DESC

关于jquery - MySql Count(sno) 按日期显示旧记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38115255/

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