日期:2014-05-16 浏览次数:20759 次
with T as ( select 1 FNO, 'aa' FName, 'J' FJD, 500 FMoney From dual union all select 1, 'aa', 'J', 300 From dual union all select 1, 'aa', 'D', 800 From dual union all select 2, 'bb', 'J', 500 From dual union all select 2, 'bb', 'J', 500 From dual union all select 2, 'bb', 'D', 800 From dual union all select 3, 'cc', 'J', 500 From dual union all select 3, 'cc', 'D', 300 From dual) SELECT * FROM T WHERE T.FNO IN (SELECT FNO FROM (select FNO,DECODE(FJD,'J',FMoney,FMoney * -1) FMoney2 from T) GROUP BY FNO HAVING SUM(FMoney2) <> 0);