oracle 查询两个字段值相同的记录

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

  

(0)
上一篇 2022年3月22日
下一篇 2022年3月22日

相关推荐