借贷不平问题的处理

select aae076, yab003, yad104, aad030, aae075, sum(yaa007)

  from (select aae076,

               yab003,

               yad104,

               aad030,

               aae075,

               decode(yaa009, '1', yaa007, -1 * yaa007) as yaa007

          from ad04a1

         where aae076 in ('100000167850956')

        union all

        select aae076,

               yab003,

               yad104,

               aad030,

               aae075,

               decode(aad032, '1', aad033, aad033 * -1) as yaa007

          from ad04

         where aae076 in ('100000167850956'))

 group by aae076, yab003, yad104, aad030, aae075

having sum(yaa007) != 0

 order by aae076, yab003, yad104, aad030, aae075;

借贷不平补充SQL功能还是比较爽的,学习。

----------------------------------------------------------

/*094098 2.2-3.31门诊个账借贷不平,请处理*/

//select  ykb053  from kb12k3 where  akb020='094098'

//and aae030 >= to_Date('2008-2-2 00:00:00','yyyy-mm-dd hh24:mi:ss')

//and yke151 <= to_date('2008-3-31 23:59:59','yyyy-mm-dd hh24:mi:ss');
// select *   from  kc24k1 where akc190 in(select akc190 from   kb03k9 where ykb053='21Y09409808041839549');
/*072290出现借贷不平现象,财务接口流水号:100000166121011



//select  *  from   kc32k1 where   aae076='100000166121011' and yad063='072290';



select  *       from  kc24k1 where akc190 in(

select  akc190  from  kc24k2 where ykb010 in(

select  ykb010  from  kb03k4 where aae075 in(


select  aae075  from  kc32k1 where aae076='100000166121011' and yad063='072290'))) ; 





你可能感兴趣的:(我的项目开发,date,sql)