oracle 查询两个字段值相同的记录
程序员文章站
2023-04-04 15:56:19
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