作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的表 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/
我是一名优秀的程序员,十分优秀!