oracle 查询两个字段值相同的记录
程序员文章站
2022-05-29 09:47:58
select A.* from tb_mend_enrol A, (select A.Typeid, A.address from tb_mend_enrol A group by A.Typeid, A.address having count(A.Typeid) >= 2 and count(A ......
select a.* from tb_mend_enrol a,
(select a.typeid, a.address from tb_mend_enrol a
group by a.typeid, a.address
having count(a.typeid) >= 2 and count(a.address) >= 2 ) b
where a.typeid = b.typeid and a.address = b.address and a.reporter='测试'
and a.reptime >= to_date('2018-08-01 00:00:00','yyyy-mm-dd hh24:mi:ss')
order by a.address, a.reptime
方法二:
select a.* from tb_mend_enrol a
where (select count(*) from tb_mend_enrol a1
where a1.typeid = a.typeid and a1.address=a.address)>1
and a.reporter='测试'
and a.reptime >= to_date('2018-08-01 00:00:00','yyyy-mm-dd hh24:mi:ss'
order by a.address
上一篇: 汉文帝根本没有参与诛灭吕后党羽的行动 为什么皇位却从天下上来呢
下一篇: 让我媳妇给你刷碗吧