经销商详情查询.sql 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. select t1.sys_enterpriseid,
  2. t1.enterprisename,
  3. t1.contact,
  4. t1.address,
  5. t1.phonenumber,
  6. t1.province,
  7. t1.city,
  8. t1.county,
  9. t2.sa_agentsid,
  10. t2.agentnum,
  11. t2.priceadjustment,
  12. t2.type,
  13. CONVERT(t1.grade, CHAR) grade,
  14. t1.industry,
  15. t1.taxno,
  16. t1.saleclassauth,
  17. t2.signdate,
  18. t2.createby,
  19. t2.createdate,
  20. t2.status,
  21. t2.parentid,
  22. (SELECT enterprisename FROM sys_enterprise WHERE sys_enterpriseid = (SELECT sys_enterpriseid FROM sa_agents WHERE sa_agentsid = t2.parentid)) parent_enterprisename,
  23. t4.erpagentnum,
  24. t2.isservice,
  25. t1.limitreturnday,
  26. t1.freefreightamount,
  27. t1.invoicingpoint,
  28. t1.isrebate
  29. from sys_enterprise t1
  30. inner join sa_agents t2 on t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid
  31. LEFT JOIN sys_dataextend t4 ON t1.sys_enterpriseid = t4.ownerid and ownertable='sys_enterprise' and t1.siteid = t4.siteid
  32. where t1.siteid = $siteid$
  33. and t2.sa_agentsid = $sa_agentsid$