查询oracle数据库是否有重复数据(根据多个字段判断)

根据多个字段查询重复数据的总条数:

sql = "select count(*) from tablea a where (a.askname, a.atime) in (select askname,atime from tablea group by askname,atime having count(*)>1) and askrepid not in (select min(askrepid) from tablea group by askname,atime having count(*)>1)"
cursor.execute(sql)
conn.commit()
tables = cursor.fetchall()
print 'result*********:',tables

猜你喜欢

转载自my.oschina.net/u/3636678/blog/2967373