这是我的第一篇文章。我已经看到类似的问题,但不明白答案。如果这已经发布过,我深表歉意。
我有一个问题,其中日历同步重复了一堆约会。我想删除除原始约会以外的所有约会。我将sql放在下面以对约会进行分组。但是我无法从群组中删除,我尝试进行Sub查询,但是不能有多个列。
该表称为Appts。我要利用提醒时间将原作与假人分开。
尝试1:
select startdate, starttime, subject, count(*)
from appts
group by startdate, starttime, subject
having count (*) > 3
尝试2:
DELETE FROM appts
WHERE subject IN (Select startdate, starttime, subject, count(*)
from appts
group by startdate, starttime, subject
having count (*) > 3)
答案 0 :(得分:0)
您可以像下面那样使用cte(如果是dbms sql服务器)
with cte as
(
select startdate, starttime, subject, count(*) from appts
group by startdate, starttime, subject having count (*) > 3
) delete from cte