货品档案详情.sql 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. SELECT t1.*,
  2. t2.unitname,
  3. t8.plm_itemextendid,
  4. t8.caliber,
  5. t8.pressure,
  6. t8.material,
  7. t8.butterflyplatedrive,
  8. t8.connection,
  9. t8.valveplatematerial,
  10. t8.bodymaterial,
  11. t8.actuatortype,
  12. t8.actuatorbrand,
  13. t8.isbutterfly,
  14. t8.erpitemno,
  15. t8.erpitemname,
  16. t8.specalnote,
  17. t8.prodline,
  18. t8.device,
  19. (case
  20. when t3.cansaleqty >= t1.stockstatus1 then '充足'
  21. when t3.cansaleqty <= t1.stockstatus2 then '缺货'
  22. else '紧缺' end) stockstatus,
  23. ifnull(t3.qty, 0) invbal_qty,
  24. t4.schemename widthschemename,
  25. t5.schemename lengthschemename,
  26. t6.schemename,
  27. ifnull(t9.price,0) price1,
  28. ifnull(t10.price,0) price2,
  29. ifnull(t11.price,0) price3,
  30. ifnull(t12.price,0) price4,
  31. ifnull(t13.price,0) price5,
  32. t14.depname,
  33. t15.stockname,
  34. t15.kw,
  35. t16.suppno,
  36. t16.suppshortname,
  37. t16.suppname
  38. FROM plm_item t1
  39. LEFT JOIN plm_unit t2 ON t2.unitid = t1.unitid AND t2.siteid = t1.siteid
  40. LEFT JOIN plm_itemextend t8 ON t8.itemid = t1.itemid AND t8.siteid = t1.siteid
  41. LEFT JOIN st_invbal_sale t3 ON t3.siteid = t1.siteid AND t3.itemid = t1.itemid
  42. left join sa_sizecustomizedscheme t4 on t1.widthschemeid=t4.sa_sizecustomizedschemeid and t1.siteid=t4.siteid
  43. left join sa_sizecustomizedscheme t5 on t1.lengthschemeid=t5.sa_sizecustomizedschemeid and t1.siteid=t5.siteid
  44. left join sa_customscheme t6 on t1.sa_customschemeid=t6.sa_customschemeid and t1.siteid=t6.siteid
  45. left join sa_itemprice t9 on t9.itemid = t1.itemid AND t9.siteid = t1.siteid and t9.pricegrade=1
  46. left join sa_itemprice t10 on t10.itemid = t1.itemid AND t10.siteid = t1.siteid and t10.pricegrade=2
  47. left join sa_itemprice t11 on t11.itemid = t1.itemid AND t11.siteid = t1.siteid and t11.pricegrade=3
  48. left join sa_itemprice t12 on t12.itemid = t1.itemid AND t12.siteid = t1.siteid and t12.pricegrade=4
  49. left join sa_itemprice t13 on t12.itemid = t1.itemid AND t12.siteid = t1.siteid and t12.pricegrade=5
  50. LEFT JOIN sys_department t14 ON t14.departmentid = t1.departmentid AND t14.siteid = t1.siteid
  51. LEFT JOIN st_stock t15 ON t15.stockno = t1.stockno AND t15.siteid = t1.siteid
  52. LEFT JOIN sa_supplier t16 ON t16.sa_supplierid = t1.sa_supplierid AND t16.siteid = t1.siteid
  53. WHERE t1.siteid = $siteid$
  54. and t1.itemid = $itemid$