|
|
@@ -1,10 +1,10 @@
|
|
|
with sa_salestarget as
|
|
|
(
|
|
|
- select 0+CAST(sum(amount) AS CHAR) amount,point,sa_saleareaid,type from (SELECT t1.amount, MONTH (t1.createdate) point,ifnull(t4.sa_saleareaid,0) sa_saleareaid,'月' type
|
|
|
+ select 0+CAST(sum(amount) AS CHAR) amount,point,sa_saleareaid,type from (SELECT t1.amount, MONTH (t1.period) point,ifnull(t4.sa_saleareaid,0) sa_saleareaid,'月' type
|
|
|
FROM sa_cashbill t1
|
|
|
left join sys_enterprise_tradefield t3 on t1.sys_enterpriseid=t3.sys_enterpriseid and t1.siteid=t3.siteid
|
|
|
left join sa_salearea t4 on t4.sa_saleareaid=t3.sa_saleareaid and t4.siteid=t3.siteid
|
|
|
-WHERE YEAR (t1.createdate)=$year$ AND t1.siteid=$siteid$ AND t1.status in('审核') and t1.type=1 and ($where1$)) a
|
|
|
+WHERE YEAR (t1.period)=$year$ AND t1.siteid=$siteid$ AND t1.status in('审核') and t1.type=1 and ($where1$)) a
|
|
|
GROUP BY point,sa_saleareaid,type
|
|
|
)
|
|
|
, hrtarget as (
|
|
|
@@ -53,23 +53,23 @@ from (
|
|
|
t2.parentid,
|
|
|
t2.areafullname,
|
|
|
1 level,
|
|
|
- ROUND(y1a/10000,2) y1a,
|
|
|
- ROUND(s1a/10000,2) s1a,
|
|
|
- ROUND(s2a/10000,2) s2a,
|
|
|
- ROUND(s3a/10000,2) s3a,
|
|
|
- ROUND(s4a/10000,2) s4a,
|
|
|
- ROUND(m1a/10000,2) m1a,
|
|
|
- ROUND(m2a/10000,2) m2a,
|
|
|
- ROUND(m3a/10000,2) m3a,
|
|
|
- ROUND(m4a/10000,2) m4a,
|
|
|
- ROUND(m5a/10000,2) m5a,
|
|
|
- ROUND(m6a/10000,2) m6a,
|
|
|
- ROUND(m7a/10000,2) m7a,
|
|
|
- ROUND(m8a/10000,2) m8a,
|
|
|
- ROUND(m9a/10000,2) m9a,
|
|
|
- ROUND(m10a/10000,2) m10a,
|
|
|
- ROUND(m11a/10000,2) m11a,
|
|
|
- ROUND(m12a/10000,2) m12a
|
|
|
+ CAST(ROUND(y1a,2) AS DECIMAL(16,2)) y1a,
|
|
|
+ CAST(ROUND(s1a,2) AS DECIMAL(16,2)) s1a,
|
|
|
+ CAST(ROUND(s2a,2) AS DECIMAL(16,2)) s2a,
|
|
|
+ CAST(ROUND(s3a,2) AS DECIMAL(16,2)) s3a,
|
|
|
+ CAST(ROUND(s4a,2) AS DECIMAL(16,2)) s4a,
|
|
|
+ CAST(ROUND(m1a,2) AS DECIMAL(16,2)) m1a,
|
|
|
+ CAST(ROUND(m2a,2) AS DECIMAL(16,2)) m2a,
|
|
|
+ CAST(ROUND(m3a,2) AS DECIMAL(16,2)) m3a,
|
|
|
+ CAST(ROUND(m4a,2) AS DECIMAL(16,2)) m4a,
|
|
|
+ CAST(ROUND(m5a,2) AS DECIMAL(16,2)) m5a,
|
|
|
+ CAST(ROUND(m6a,2) AS DECIMAL(16,2)) m6a,
|
|
|
+ CAST(ROUND(m7a,2) AS DECIMAL(16,2)) m7a,
|
|
|
+ CAST(ROUND(m8a,2) AS DECIMAL(16,2)) m8a,
|
|
|
+ CAST(ROUND(m9a,2) AS DECIMAL(16,2)) m9a,
|
|
|
+ CAST(ROUND(m10a,2) AS DECIMAL(16,2)) m10a,
|
|
|
+ CAST(ROUND(m11a,2) AS DECIMAL(16,2)) m11a,
|
|
|
+ CAST(ROUND(m12a,2) AS DECIMAL(16,2)) m12a
|
|
|
from hrtarget t1
|
|
|
INNER JOIN sa_salearea t2 ON t2.sa_saleareaid = t1.sa_saleareaid
|
|
|
union all
|
|
|
@@ -79,26 +79,26 @@ from (
|
|
|
t6.parentid,
|
|
|
t6.areafullname,
|
|
|
0 level,
|
|
|
- ROUND(sum(y1a)/10000,2) y1a,
|
|
|
- ROUND(sum(s1a)/10000,2) s1a,
|
|
|
- ROUND(sum(s2a)/10000,2) s2a,
|
|
|
- ROUND(sum(s3a)/10000,2) s3a,
|
|
|
- ROUND(sum(s4a)/10000,2) s4a,
|
|
|
- ROUND(sum(m1a)/10000,2) m1a,
|
|
|
- ROUND(sum(m2a)/10000,2) m2a,
|
|
|
- ROUND(sum(m3a)/10000,2) m3a,
|
|
|
- ROUND(sum(m4a)/10000,2) m4a,
|
|
|
- ROUND(sum(m5a)/10000,2) m5a,
|
|
|
- ROUND(sum(m6a)/10000,2) m6a,
|
|
|
- ROUND(sum(m7a)/10000,2) m7a,
|
|
|
- ROUND(sum(m8a)/10000,2) m8a,
|
|
|
- ROUND(sum(m9a)/10000,2) m9a,
|
|
|
- ROUND(sum(m10a)/10000,2) m10a,
|
|
|
- ROUND(sum(m11a)/10000,2) m11a,
|
|
|
- ROUND(sum(m12a)/10000,2) m12a
|
|
|
+ CAST(ROUND(sum(y1a),2) AS DECIMAL(16,2)) y1a,
|
|
|
+ CAST(ROUND(sum(s1a),2) AS DECIMAL(16,2)) s1a,
|
|
|
+ CAST(ROUND(sum(s2a),2) AS DECIMAL(16,2)) s2a,
|
|
|
+ CAST(ROUND(sum(s3a),2) AS DECIMAL(16,2)) s3a,
|
|
|
+ CAST(ROUND(sum(s4a),2) AS DECIMAL(16,2)) s4a,
|
|
|
+ CAST(ROUND(sum(m1a),2) AS DECIMAL(16,2)) m1a,
|
|
|
+ CAST(ROUND(sum(m2a),2) AS DECIMAL(16,2)) m2a,
|
|
|
+ CAST(ROUND(sum(m3a),2) AS DECIMAL(16,2)) m3a,
|
|
|
+ CAST(ROUND(sum(m4a),2) AS DECIMAL(16,2)) m4a,
|
|
|
+ CAST(ROUND(sum(m5a),2) AS DECIMAL(16,2)) m5a,
|
|
|
+ CAST(ROUND(sum(m6a),2) AS DECIMAL(16,2)) m6a,
|
|
|
+ CAST(ROUND(sum(m7a),2) AS DECIMAL(16,2)) m7a,
|
|
|
+ CAST(ROUND(sum(m8a),2) AS DECIMAL(16,2)) m8a,
|
|
|
+ CAST(ROUND(sum(m9a),2) AS DECIMAL(16,2)) m9a,
|
|
|
+ CAST(ROUND(sum(m10a),2) AS DECIMAL(16,2)) m10a,
|
|
|
+ CAST(ROUND(sum(m11a),2) AS DECIMAL(16,2)) m11a,
|
|
|
+ CAST(ROUND(sum(m12a),2) AS DECIMAL(16,2)) m12a
|
|
|
from hrtarget t1
|
|
|
left join sa_salearea t5 on t1.sa_saleareaid = t5.sa_saleareaid
|
|
|
left join sa_salearea t6 on t5.parentid = t6.sa_saleareaid and t5.siteid = t6.siteid
|
|
|
group by t6.sa_saleareaid, t6.areafullname, t6.areaname) t
|
|
|
where $where$
|
|
|
-order by areafullname, case when t.type = '区域' then 0 else 1 end
|
|
|
+order by case when t.type = '区域汇总' then 0 else 1 end
|