|
|
@@ -1,44 +1,21 @@
|
|
|
with sa_salestarget as (
|
|
|
- select 0+CAST(sum(amount) AS CHAR) amount,point,sys_enterpriseid,year from(SELECT (t5.qty*t1.price) amount, MONTH (t6.checkdate) point,ifnull(t2.sys_enterpriseid,0) sys_enterpriseid,YEAR(t6.checkdate) year
|
|
|
+ select 0+CAST(sum(amount) AS CHAR) amount,point,sys_enterpriseid,year from(SELECT (t5.qty*t1.price) amount, QUARTER(t6.checkdate) point,ifnull(t6.sys_enterpriseid,0) sys_enterpriseid,YEAR(t6.checkdate) year
|
|
|
FROM sa_orderitems t1
|
|
|
- LEFT JOIN sa_order t2 ON t1.sa_orderid=t2.sa_orderid AND t1.siteid=t2.siteid
|
|
|
- left join sys_enterprise_tradefield t3 on t2.sys_enterpriseid=t3.sys_enterpriseid and t2.siteid=t3.siteid
|
|
|
- left join sa_salearea t4 on t4.sa_saleareaid=t3.sa_saleareaid and t4.siteid=t3.siteid
|
|
|
inner join st_stockbill_items t5 ON t5.sa_orderitemsid = t1.sa_orderitemsid AND t5.siteid = t1.siteid
|
|
|
inner join st_stockbill t6 ON t6.st_stockbillid = t5.st_stockbillid AND t6.siteid = t5.siteid
|
|
|
-WHERE YEAR (t6.checkdate)=$year$ and t2.sys_enterpriseid in $sys_enterpriseid$ AND t1.siteid=$siteid$ and t6.rb=1) a
|
|
|
+WHERE YEAR (t6.checkdate)=$year$ and t2.sys_enterpriseid in $sys_enterpriseid$ AND t1.siteid=$siteid$ and t6.type='销售出库' and t6.rb=1) a
|
|
|
GROUP BY point,sys_enterpriseid,year
|
|
|
)
|
|
|
SELECT DISTINCT m.year,
|
|
|
m.sys_enterpriseid,
|
|
|
- ROUND((ifnull(m1.amount,0)+ ifnull(m2.amount,0)+ifnull(m3.amount,0)+ ifnull(m4.amount,0)+ ifnull(m5.amount,0)+ ifnull(m6.amount,0)+ ifnull(m7.amount,0)+ ifnull(m8.amount,0)+ ifnull(m9.amount,0) + ifnull(m10.amount,0)+ ifnull(m11.amount,0)+ ifnull(m12.amount,0))/10000,$num$) as y1a,
|
|
|
- ROUND((ifnull(m1.amount,0)+ ifnull(m2.amount,0)+ifnull(m3.amount,0))/10000,$num$) as s1a,
|
|
|
- ROUND((ifnull(m4.amount,0)+ ifnull(m5.amount,0)+ifnull(m6.amount,0))/10000,$num$) as s2a,
|
|
|
- ROUND((ifnull(m7.amount,0)+ ifnull(m8.amount,0)+ifnull(m9.amount,0))/10000,$num$) as s3a,
|
|
|
- ROUND((ifnull(m10.amount,0)+ ifnull(m11.amount,0)+ifnull(m12.amount,0))/10000,$num$) as s4a,
|
|
|
- ROUND(ifnull(m1.amount,0)/10000,$num$) as m1a,
|
|
|
- ROUND(ifnull(m2.amount,0)/10000,$num$) as m2a,
|
|
|
- ROUND(ifnull(m3.amount,0)/10000,$num$) as m3a,
|
|
|
- ROUND(ifnull(m4.amount,0)/10000,$num$)as m4a,
|
|
|
- ROUND(ifnull(m5.amount,0)/10000,$num$) as m5a,
|
|
|
- ROUND(ifnull(m6.amount,0)/10000,$num$) as m6a,
|
|
|
- ROUND(ifnull(m7.amount,0)/10000,$num$) as m7a,
|
|
|
- ROUND(ifnull(m8.amount,0)/10000,$num$) as m8a,
|
|
|
- ROUND(ifnull(m9.amount,0)/10000,$num$) as m9a,
|
|
|
- ROUND(ifnull(m10.amount,0)/10000,$num$) as m10a,
|
|
|
- ROUND(ifnull(m11.amount,0)/10000,$num$) as m11a,
|
|
|
- ROUND(ifnull(m12.amount,0)/10000,$num$) as m12a
|
|
|
+ ROUND((ifnull(m1.amount,0)+ ifnull(m2.amount,0)+ifnull(m3.amount,0)+ ifnull(m4.amount,0))/10000,$num$) as y1a,
|
|
|
+ ROUND((ifnull(m1.amount,0))/10000,$num$) as s1a,
|
|
|
+ ROUND((ifnull(m2.amount,0))/10000,$num$) as s2a,
|
|
|
+ ROUND((ifnull(m3.amount,0))/10000,$num$) as s3a,
|
|
|
+ ROUND((ifnull(m4.amount,0))/10000,$num$) as s4a
|
|
|
from sa_salestarget m
|
|
|
LEFT JOIN sa_salestarget m1 ON m1.year = m.year and m1.point = 1 and m.sys_enterpriseid = m1.sys_enterpriseid
|
|
|
LEFT JOIN sa_salestarget m2 ON m2.year = m.year and m2.point = 2 and m.sys_enterpriseid = m2.sys_enterpriseid
|
|
|
LEFT JOIN sa_salestarget m3 ON m3.year = m.year and m3.point = 3 and m.sys_enterpriseid = m3.sys_enterpriseid
|
|
|
LEFT JOIN sa_salestarget m4 ON m4.year = m.year and m4.point = 4 and m.sys_enterpriseid = m4.sys_enterpriseid
|
|
|
- LEFT JOIN sa_salestarget m5 ON m5.year = m.year and m5.point = 5 and m.sys_enterpriseid = m5.sys_enterpriseid
|
|
|
- LEFT JOIN sa_salestarget m6 ON m6.year = m.year and m6.point = 6 and m.sys_enterpriseid = m6.sys_enterpriseid
|
|
|
- LEFT JOIN sa_salestarget m7 ON m7.year = m.year and m7.point = 7 and m.sys_enterpriseid = m7.sys_enterpriseid
|
|
|
- LEFT JOIN sa_salestarget m8 ON m8.year = m.year and m8.point = 8 and m.sys_enterpriseid = m8.sys_enterpriseid
|
|
|
- LEFT JOIN sa_salestarget m9 ON m9.year = m.year and m9.point = 9 and m.sys_enterpriseid = m9.sys_enterpriseid
|
|
|
- LEFT JOIN sa_salestarget m10 ON m10.year = m.year and m10.point = 10 and m.sys_enterpriseid = m10.sys_enterpriseid
|
|
|
- LEFT JOIN sa_salestarget m11 ON m11.year = m.year and m11.point = 11 and m.sys_enterpriseid = m11.sys_enterpriseid
|
|
|
- LEFT JOIN sa_salestarget m12 ON m12.year = m.year and m12.point = 12 and m.sys_enterpriseid = m12.sys_enterpriseid
|
|
|
ORDER BY m.year desc
|