日期:2014-05-18 浏览次数:20438 次
SELECT a.* FROM cardtran a join (SELECT cardno, balance FROM cardtran GROUP BY (cardno, balance) HAVING COUNT(*) > 1) b on a.cardno = b.cardno and a.balance = b.balance
------解决方案--------------------
select t1.* from cardtran t1 where exists ( select 1 from cardtran t2 where t1.cardno=t2.cardno and t1.balance=t2.balance group by t2.cardno,t2.balance having count(1)>1 )
------解决方案--------------------
其實二樓的改一點就可以了
SELECT a.* FROM cardtran a join (SELECT cardno, balance FROM cardtran GROUP BY cardno, balance--去掉括號 HAVING COUNT(*) > 1) b on a.cardno = b.cardno and a.balance = b.balance