Compare commits
2 Commits
cd8d2cb6bb
...
fbb6b4f976
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbb6b4f976 | ||
|
|
b14b28fbee |
@@ -1161,38 +1161,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
|
|
||||||
<select id="selectNewGrBiSaAggGroupHZList" resultType="java.util.Map">
|
<select id="selectNewGrBiSaAggGroupHZList" resultType="java.util.Map">
|
||||||
SELECT
|
select t.* from (
|
||||||
'自营品种' as bk,
|
SELECT
|
||||||
IF(GROUPING (saler_name, zone_name) = 2, CONCAT(zone_name, "总计"), IFNULL(zone_name, '省区合计')) AS zone_name,
|
'自营品种' as bk,
|
||||||
c.position,
|
IF(GROUPING (saler_name, zone_name) = 2, CONCAT(zone_name, "总计"), IFNULL(zone_name, '省区合计')) AS zone_name,
|
||||||
saler_name,
|
c.position,
|
||||||
-- GROUPING (saler_name, zone_name, c.position),
|
saler_name,
|
||||||
ROUND(SUM(IF(`use_month` = '1', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_1,
|
-- GROUPING (saler_name, zone_name, c.position),
|
||||||
ROUND(SUM(IF(`use_month` = '2', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_2,
|
ROUND(SUM(IF(`use_month` = '1', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_1,
|
||||||
ROUND(SUM(IF(`use_month` = '3', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_3,
|
ROUND(SUM(IF(`use_month` = '2', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_2,
|
||||||
ROUND(SUM(IF(`use_month` = '4', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_4,
|
ROUND(SUM(IF(`use_month` = '3', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_3,
|
||||||
ROUND(SUM(IF(`use_month` = '5', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_5,
|
ROUND(SUM(IF(`use_month` = '4', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_4,
|
||||||
ROUND(SUM(IF(`use_month` = '6', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_6,
|
ROUND(SUM(IF(`use_month` = '5', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_5,
|
||||||
ROUND(SUM(IF(`use_month` = '7', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_7,
|
ROUND(SUM(IF(`use_month` = '6', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_6,
|
||||||
ROUND(SUM(IF(`use_month` = '8', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_8,
|
ROUND(SUM(IF(`use_month` = '7', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_7,
|
||||||
ROUND(SUM(IF(`use_month` = '9', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_9,
|
ROUND(SUM(IF(`use_month` = '8', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_8,
|
||||||
ROUND(SUM(IF(`use_month` = '10', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_10,
|
ROUND(SUM(IF(`use_month` = '9', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_9,
|
||||||
ROUND(SUM(IF(`use_month` = '11', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_11,
|
ROUND(SUM(IF(`use_month` = '10', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_10,
|
||||||
ROUND(SUM(IF(`use_month` = '12', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_12,
|
ROUND(SUM(IF(`use_month` = '11', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_11,
|
||||||
ROUND(SUM(this_month_sa_money) / 10000, 2) AS year_sa_money
|
ROUND(SUM(IF(`use_month` = '12', this_month_sa_money, null)) / 10000, 2) AS month_sa_money_12,
|
||||||
FROM
|
ROUND(SUM(this_month_sa_money) / 10000, 2) AS year_sa_money
|
||||||
new_gr_bi_sa_agg_month_count a
|
FROM
|
||||||
LEFT JOIN gr_report.gr_contacts c ON a.saler_name = c.`name`
|
new_gr_bi_sa_agg_month_count a
|
||||||
AND a.zone_name = c.zone
|
LEFT JOIN gr_report.gr_contacts c ON a.saler_name = c.`name`
|
||||||
WHERE
|
AND a.zone_name = c.zone
|
||||||
use_year = YEAR(CURDATE())
|
WHERE
|
||||||
AND sale_type_name = '自营品种'
|
use_year = YEAR(CURDATE())
|
||||||
GROUP BY
|
AND sale_type_name = '自营品种'
|
||||||
zone_name,
|
GROUP BY
|
||||||
saler_name,
|
zone_name,
|
||||||
c.position WITH ROLLUP
|
saler_name,
|
||||||
|
c.position WITH ROLLUP
|
||||||
|
|
||||||
HAVING GROUPING (saler_name, zone_name, c.position) != 1
|
HAVING GROUPING (saler_name, zone_name, c.position) != 1 ORDER BY a.zone_name DESC, zone_name ASC, c.position IS NULL , c.position DESC
|
||||||
|
) t
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
Reference in New Issue
Block a user