我的表ANSWERS_T是
id answer_date_val event_id
.. ... ...
103 2019-10-18 09:30:00.000 145
104 2019-10-18 09:35:00.000 145
105 2019-10-18 10:45:00.000 146
106 2019-10-18 10:50:00.000 146
..
我的查询需要找到ANSWERS_T行,其中同一event_id有多个相同的answer_date_val。
这是在Postgres中。
如果您需要answer_date_val和event_id的重复条目,则可以尝试使用子查询来重复连接到基表
select *
from ANSWERS_T a
inner join (
select event_id, answer_date_val
from ANSWERS_T
group by event_id, answer_date_val
having count(*) >= 2
) t on t.event_id= a.event_id
and t.answer_date_val = a.answer_date_val
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句