gpt4 book ai didi

SQL/Postgres : Find Tuple with Same Value (for a Given Value in another column)

转载 作者:行者123 更新时间:2023-11-29 12:48:55 25 4
gpt4 key购买 nike

我的表 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

关于SQL/Postgres : Find Tuple with Same Value (for a Given Value in another column),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58456505/

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