我试图返回过去 8 天内收到的 the_id 的所有值,并且至少有 1 个重复的名称。这应该返回 1,5。
SELECT the_id, count(*) c
FROM "MYTABLE"
WHERE "received" < date('now','-8 days')
GROUP BY the_name HAVING c > 1;
这可能对你有用:
SELECT a.the_id
FROM "MYTABLE" A, "MYTABLE" B
WHERE (a.the_name = b.the_name)
AND
(a."received" < date('now','-8 days')
AND b."received" < date('now','-8 days')
)
Group by a.the_id
having count(*)>1