答案 0 :(得分:0)
您似乎每次都在寻找四个记录。您可以使用窗口功能:
select t.*
from (select t.*,
count(*) over (partition by id, datetime) as cnt
from t
) t
where cnt = 4;
如果您不知道频道数,可以使用:
select t.*
from (select t.*,
count(*) over (partition by id, datetime) as cnt,
count(distinct channel) over () as num_channel
from t
) t
where cnt = num_channel;
答案 1 :(得分:0)
尝试一下-
SELECT * FROM your_table
WHERE DateTime IN
(
SELECT DateTime
FROM your_table
GROUP BY DateTime
HAVING COUNT(DISTINCT Chanel) = 4
)