Browse Source

修改居民数计算方式

feature/yujt_analysisHomeChange v2.3.1.200901.Release
yujt 5 years ago
parent
commit
4c65445992
  1. 151
      epdc-cloud-analysis/doc/kettle/analysis-yushan/analysis_extracting/epdc_user_statistics_extracting.ktr

151
epdc-cloud-analysis/doc/kettle/analysis-yushan/analysis_extracting/epdc_user_statistics_extracting.ktr

@ -436,9 +436,10 @@
</info> </info>
<notepads> <notepads>
<notepad> <notepad>
<note>榆山居民数,不计入未认证数。 <note>-- 不计入未认证居民数。
若计入未认证居民数,请使用原sql:
SELECT total.GRID_ID, SELECT
total.GRID_ID,
SUM( total.USER_TOTAL + total.COMPANY_REPRESENT_TOTAL ) AS USER_TOTAL, SUM( total.USER_TOTAL + total.COMPANY_REPRESENT_TOTAL ) AS USER_TOTAL,
SUM( total.RESIDENTS_TOTAL ) AS RESIDENTS_TOTAL, SUM( total.RESIDENTS_TOTAL ) AS RESIDENTS_TOTAL,
SUM( total.PARTY_TOTAL ) AS PARTY_TOTAL, SUM( total.PARTY_TOTAL ) AS PARTY_TOTAL,
@ -446,69 +447,46 @@ SELECT total.GRID_ID,
SUM( total.UNDER_FIFTY_PARTY_TOTAL ) AS UNDER_FIFTY_PARTY_TOTAL, SUM( total.UNDER_FIFTY_PARTY_TOTAL ) AS UNDER_FIFTY_PARTY_TOTAL,
SUM( total.COMPANY_REPRESENT_TOTAL ) AS COMPANY_REPRESENT_TOTAL, SUM( total.COMPANY_REPRESENT_TOTAL ) AS COMPANY_REPRESENT_TOTAL,
NOW() AS CREATED_TIME NOW() AS CREATED_TIME
from FROM (
(SELECT SELECT
t1.GRID_ID, t1.GRID_ID, t1.USER_TOTAL,
t1.USER_TOTAL,
( t1.USER_TOTAL - t1.PARTY_TOTAL) AS RESIDENTS_TOTAL, ( t1.USER_TOTAL - t1.PARTY_TOTAL) AS RESIDENTS_TOTAL,
t1.PARTY_TOTAL, t1.PARTY_TOTAL, t1.OVER_FIFTY_PARTY_TOTAL,
t1.OVER_FIFTY_PARTY_TOTAL,
(t1.PARTY_TOTAL - t1.OVER_FIFTY_PARTY_TOTAL) AS UNDER_FIFTY_PARTY_TOTAL, (t1.PARTY_TOTAL - t1.OVER_FIFTY_PARTY_TOTAL) AS UNDER_FIFTY_PARTY_TOTAL,
0 AS COMPANY_REPRESENT_TOTAL 0 AS COMPANY_REPRESENT_TOTAL
FROM FROM (
(
SELECT SELECT
t.GRID_ID, t.GRID_ID, COUNT( t.ID ) AS USER_TOTAL,
COUNT( t.ID ) AS USER_TOTAL,
SUM( t.PARTY_FLAG = 1 ) AS PARTY_TOTAL, SUM( t.PARTY_FLAG = 1 ) AS PARTY_TOTAL,
SUM( t.age >= 50 AND t.PARTY_FLAG = 1 ) AS OVER_FIFTY_PARTY_TOTAL SUM( t.age >= 50 AND t.PARTY_FLAG = 1 ) AS OVER_FIFTY_PARTY_TOTAL
FROM FROM (
(
SELECT SELECT
eu.ID, eu.ID, eu.PARTY_FLAG,
eu.PARTY_FLAG,
IFNULL( TIMESTAMPDIFF( YEAR, eu.BIRTHDAY, CURDATE()), 0 ) AS age, IFNULL( TIMESTAMPDIFF( YEAR, eu.BIRTHDAY, CURDATE()), 0 ) AS age,
CASE CASE WHEN eu.DEPT_ID IS NOT NULL AND eu.DEPT_ID &lt;&gt; 0 THEN eu.DEPT_ID ELSE '' END AS GRID_ID
WHEN eu.DEPT_ID IS NOT NULL
AND eu.DEPT_ID &lt;&gt; 0 THEN
eu.DEPT_ID ELSE (
SELECT
eugr.GRID_ID
FROM
meta_epdc_user_grid_relation eugr
WHERE
eugr.DEL_FLAG = '0'
AND eugr.USER_ID = eu.ID
ORDER BY
CREATED_TIME
LIMIT 1
)
END AS GRID_ID
FROM FROM
meta_epdc_user eu meta_epdc_user eu
WHERE WHERE
eu.DEL_FLAG = '0' eu.DEL_FLAG = '0'
) t ) t
where t.grid_id != '' WHERE t.grid_id != ''
GROUP BY t.GRID_ID GROUP BY t.GRID_ID
) t1 ) t1 UNION ALL
UNION ALL SELECT
select DEPT_ID AS GRID_ID, DEPT_ID AS GRID_ID, 0 AS USER_TOTAL, 0 AS RESIDENTS_TOTAL, 0 AS PARTY_TOTAL,
0 AS USER_TOTAL, 0 AS OVER_FIFTY_PARTY_TOTAL, 0 AS UNDER_FIFTY_PARTY_TOTAL, COUNT( ID ) AS COMPANY_REPRESENT_TOTAL
0 AS RESIDENTS_TOTAL, FROM
0 AS PARTY_TOTAL, meta_epdc_enterprise_info
0 AS OVER_FIFTY_PARTY_TOTAL,
0 AS UNDER_FIFTY_PARTY_TOTAL,
COUNT(ID) AS COMPANY_REPRESENT_TOTAL
FROM meta_epdc_enterprise_info
WHERE DEL_FLAG = 0 WHERE DEL_FLAG = 0
GROUP BY DEPT_ID)total GROUP BY DEPT_ID
group by total.GRID_ID</note> ) total
GROUP BY
total.GRID_ID
</note>
<xloc>327</xloc> <xloc>327</xloc>
<yloc>339</yloc> <yloc>339</yloc>
<width>670</width> <width>822</width>
<heigth>1115</heigth> <heigth>764</heigth>
<fontname>Microsoft YaHei UI</fontname> <fontname>Microsoft YaHei UI</fontname>
<fontsize>9</fontsize> <fontsize>9</fontsize>
<fontbold>N</fontbold> <fontbold>N</fontbold>
@ -660,8 +638,7 @@ UNION ALL
<schema_name/> <schema_name/>
</partitioning> </partitioning>
<connection>esua_epdc_analysis</connection> <connection>esua_epdc_analysis</connection>
<sql>SELECT <sql>SELECT total.GRID_ID,
total.GRID_ID,
SUM(total.USER_TOTAL+total.COMPANY_REPRESENT_TOTAL) AS USER_TOTAL, SUM(total.USER_TOTAL+total.COMPANY_REPRESENT_TOTAL) AS USER_TOTAL,
SUM(total.RESIDENTS_TOTAL) AS RESIDENTS_TOTAL, SUM(total.RESIDENTS_TOTAL) AS RESIDENTS_TOTAL,
SUM(total.PARTY_TOTAL) AS PARTY_TOTAL, SUM(total.PARTY_TOTAL) AS PARTY_TOTAL,
@ -669,41 +646,65 @@ UNION ALL
SUM(total.UNDER_FIFTY_PARTY_TOTAL) AS UNDER_FIFTY_PARTY_TOTAL, SUM(total.UNDER_FIFTY_PARTY_TOTAL) AS UNDER_FIFTY_PARTY_TOTAL,
SUM(total.COMPANY_REPRESENT_TOTAL) AS COMPANY_REPRESENT_TOTAL, SUM(total.COMPANY_REPRESENT_TOTAL) AS COMPANY_REPRESENT_TOTAL,
NOW() AS CREATED_TIME NOW() AS CREATED_TIME
FROM ( from
SELECT (SELECT
t1.GRID_ID, t1.USER_TOTAL, t1.GRID_ID,
t1.USER_TOTAL,
( t1.USER_TOTAL - t1.PARTY_TOTAL ) AS RESIDENTS_TOTAL, ( t1.USER_TOTAL - t1.PARTY_TOTAL ) AS RESIDENTS_TOTAL,
t1.PARTY_TOTAL, t1.OVER_FIFTY_PARTY_TOTAL, t1.PARTY_TOTAL,
t1.OVER_FIFTY_PARTY_TOTAL,
( t1.PARTY_TOTAL - t1.OVER_FIFTY_PARTY_TOTAL ) AS UNDER_FIFTY_PARTY_TOTAL, ( t1.PARTY_TOTAL - t1.OVER_FIFTY_PARTY_TOTAL ) AS UNDER_FIFTY_PARTY_TOTAL,
0 AS COMPANY_REPRESENT_TOTAL 0 AS COMPANY_REPRESENT_TOTAL
FROM ( FROM
(
SELECT SELECT
t.GRID_ID, COUNT( t.ID ) AS USER_TOTAL, t.GRID_ID,
COUNT( t.ID ) AS USER_TOTAL,
SUM( t.PARTY_FLAG = 1 ) AS PARTY_TOTAL, SUM( t.PARTY_FLAG = 1 ) AS PARTY_TOTAL,
SUM( t.age >= 50 AND t.PARTY_FLAG = 1 ) AS OVER_FIFTY_PARTY_TOTAL SUM( t.age >= 50 AND t.PARTY_FLAG = 1 ) AS OVER_FIFTY_PARTY_TOTAL
FROM ( FROM
(
SELECT SELECT
eu.ID, eu.PARTY_FLAG, eu.ID,
eu.PARTY_FLAG,
IFNULL( TIMESTAMPDIFF( YEAR, eu.BIRTHDAY, CURDATE( ) ), 0 ) AS age, IFNULL( TIMESTAMPDIFF( YEAR, eu.BIRTHDAY, CURDATE( ) ), 0 ) AS age,
CASE WHEN eu.DEPT_ID IS NOT NULL AND eu.DEPT_ID &lt;&gt; 0 THEN eu.DEPT_ID ELSE '' END AS GRID_ID CASE
WHEN eu.DEPT_ID IS NOT NULL
AND eu.DEPT_ID &lt;&gt; 0 THEN
eu.DEPT_ID ELSE (
SELECT
eugr.GRID_ID
FROM
meta_epdc_user_grid_relation eugr
WHERE
eugr.DEL_FLAG = '0'
AND eugr.USER_ID = eu.ID
ORDER BY
CREATED_TIME
LIMIT 1
)
END AS GRID_ID
FROM FROM
meta_epdc_user eu meta_epdc_user eu
WHERE WHERE
eu.DEL_FLAG = '0' eu.DEL_FLAG = '0'
) t ) t
WHERE t.grid_id != '' where t.grid_id != ''
GROUP BY t.GRID_ID GROUP BY t.GRID_ID
) t1 UNION ALL ) t1
SELECT UNION ALL
DEPT_ID AS GRID_ID, 0 AS USER_TOTAL, 0 AS RESIDENTS_TOTAL, 0 AS PARTY_TOTAL, select DEPT_ID AS GRID_ID,
0 AS OVER_FIFTY_PARTY_TOTAL, 0 AS UNDER_FIFTY_PARTY_TOTAL, COUNT( ID ) AS COMPANY_REPRESENT_TOTAL 0 AS USER_TOTAL,
FROM 0 AS RESIDENTS_TOTAL,
meta_epdc_enterprise_info 0 AS PARTY_TOTAL,
0 AS OVER_FIFTY_PARTY_TOTAL,
0 AS UNDER_FIFTY_PARTY_TOTAL,
COUNT(ID) AS COMPANY_REPRESENT_TOTAL
FROM meta_epdc_enterprise_info
WHERE DEL_FLAG=0 WHERE DEL_FLAG=0
GROUP BY DEPT_ID GROUP BY DEPT_ID)total
) total group by total.GRID_ID</sql>
GROUP BY
total.GRID_ID</sql>
<limit>0</limit> <limit>0</limit>
<lookup/> <lookup/>
<execute_each_row>N</execute_each_row> <execute_each_row>N</execute_each_row>
@ -712,14 +713,14 @@ GROUP BY
<cached_row_meta_active>N</cached_row_meta_active> <cached_row_meta_active>N</cached_row_meta_active>
<row-meta> <row-meta>
<value-meta> <value-meta>
<type>String</type> <type>Integer</type>
<storagetype>normal</storagetype> <storagetype>normal</storagetype>
<name>GRID_ID</name> <name>GRID_ID</name>
<length>20</length> <length>15</length>
<precision>-1</precision> <precision>0</precision>
<origin>表输入</origin> <origin>表输入</origin>
<comments>GRID_ID</comments> <comments>GRID_ID</comments>
<conversion_Mask/> <conversion_Mask>####0;-####0</conversion_Mask>
<decimal_symbol>.</decimal_symbol> <decimal_symbol>.</decimal_symbol>
<grouping_symbol>,</grouping_symbol> <grouping_symbol>,</grouping_symbol>
<currency_symbol/> <currency_symbol/>

Loading…
Cancel
Save