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

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM