56914
如果增加两个公司怎么处理呢?现在我只实现增加一个
!@@!#下面的是我的sql 第三行对应的为增加的公司
select r.r_idno,r.r_name,
sum(case when dept_no='1' then total_money else 0 end),
sum(case when dept_no='2' then total_money else 0 end),
${if(len(deptNo)==0||deptNo==0||deptNo=='0',"","sum(case when dept_no='"+deptNo+"' then total_money else 0 end) as deptm,")}
sum(case when dept_no='3' then total_money else 0 end)
from tk_finance_dcard_log_rt f left join
(select distinct r_name,r_idno,cardno from basic_retire_info) r on f.opcard_no=substr(r.cardno,length(r.cardno)-15,16)
where 1=1 and allot_time=to_date('${if(len($startDate)==0,today(),$startDate)}','YYYY-MM-DD')
${if(len($idNo)==0,""," and r.r_idno='"+$idNo+"'")}
${if(len(totalMoney)==0||totalMoney==0||totalMoney=='0'," "," and f.total_money <= ("+totalMoney+")")}
group by r.r_idno,r.r_name
order by r.r_idno,r.r_name