回款记录.sql 1.1 KB

12345678910111213141516171819202122232425262728
  1. select t1.sa_writeoffbillid,
  2. t1.createuserid,
  3. t1.createby,
  4. t1.createdate,
  5. t1.checkby,
  6. t1.checkdate,
  7. t1.billnodate,
  8. t1.status,
  9. t1.sys_enterpriseid,
  10. t2.enterprisename,
  11. t2.abbreviation,
  12. t1.billno writeoffbillidbillno,
  13. t1.remarks,
  14. t1.unwriteoffamount,
  15. t1.writeoffamount,
  16. t1.sa_cashbillid,
  17. t4.billno cashbillidbillno,
  18. t5.agentnum
  19. from sa_writeoffbill t1
  20. left join sys_enterprise t2
  21. on t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid
  22. left join sa_agents t5 on t2.siteid = t5.siteid and t2.sys_enterpriseid = t5.sys_enterpriseid
  23. left join sa_accountclass t3 on t1.siteid = t3.siteid and t1.sa_accountclassid = t3.sa_accountclassid
  24. left join sa_cashbill t4 on t1.siteid = t4.siteid and t1.sa_cashbillid = t4.sa_cashbillid
  25. where t1.siteid = $siteid$
  26. and t1.sa_writeoffbillid in
  27. (SELECT sa_writeoffbillid from sa_writeoffbill_order WHERE sa_orderid = $sa_orderid$ and siteid = $siteid$)
  28. and $where$