Browse Source

修改居民数计算方式

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

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

@ -436,79 +436,57 @@
</info> </info>
<notepads> <notepads>
<notepad> <notepad>
<note>榆山居民数,不计入未认证数。 <note>-- 不计入未认证居民数。
若计入未认证居民数,请使用原sql:
SELECT total.GRID_ID, SELECT
SUM(total.USER_TOTAL+total.COMPANY_REPRESENT_TOTAL) AS USER_TOTAL, total.GRID_ID,
SUM(total.RESIDENTS_TOTAL) AS RESIDENTS_TOTAL, SUM( total.USER_TOTAL + total.COMPANY_REPRESENT_TOTAL ) AS USER_TOTAL,
SUM(total.PARTY_TOTAL) AS PARTY_TOTAL, SUM( total.RESIDENTS_TOTAL ) AS RESIDENTS_TOTAL,
SUM(total.OVER_FIFTY_PARTY_TOTAL) AS OVER_FIFTY_PARTY_TOTAL, SUM( total.PARTY_TOTAL ) AS PARTY_TOTAL,
SUM(total.UNDER_FIFTY_PARTY_TOTAL) AS UNDER_FIFTY_PARTY_TOTAL, SUM( total.OVER_FIFTY_PARTY_TOTAL ) AS OVER_FIFTY_PARTY_TOTAL,
SUM(total.COMPANY_REPRESENT_TOTAL) AS COMPANY_REPRESENT_TOTAL, SUM( total.UNDER_FIFTY_PARTY_TOTAL ) AS UNDER_FIFTY_PARTY_TOTAL,
NOW() AS CREATED_TIME SUM( total.COMPANY_REPRESENT_TOTAL ) AS COMPANY_REPRESENT_TOTAL,
from NOW() AS CREATED_TIME
(SELECT FROM (
t1.GRID_ID, SELECT
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.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
( t.GRID_ID, COUNT( t.ID ) AS USER_TOTAL,
SUM( t.PARTY_FLAG = 1 ) AS PARTY_TOTAL,
SUM( t.age >= 50 AND t.PARTY_FLAG = 1 ) AS OVER_FIFTY_PARTY_TOTAL
FROM (
SELECT SELECT
t.GRID_ID, eu.ID, eu.PARTY_FLAG,
COUNT( t.ID ) AS USER_TOTAL, IFNULL( TIMESTAMPDIFF( YEAR, eu.BIRTHDAY, CURDATE()), 0 ) AS age,
SUM( t.PARTY_FLAG = 1 ) AS PARTY_TOTAL, CASE WHEN eu.DEPT_ID IS NOT NULL AND eu.DEPT_ID &lt;&gt; 0 THEN eu.DEPT_ID ELSE '' END AS GRID_ID
SUM( t.age >= 50 AND t.PARTY_FLAG = 1 ) AS OVER_FIFTY_PARTY_TOTAL
FROM FROM
( meta_epdc_user eu
SELECT WHERE
eu.ID, eu.DEL_FLAG = '0'
eu.PARTY_FLAG, ) t
IFNULL( TIMESTAMPDIFF( YEAR, eu.BIRTHDAY, CURDATE( ) ), 0 ) AS age, WHERE t.grid_id != ''
CASE GROUP BY t.GRID_ID
) t1 UNION ALL
WHEN eu.DEPT_ID IS NOT NULL SELECT
AND eu.DEPT_ID &lt;&gt; 0 THEN DEPT_ID AS GRID_ID, 0 AS USER_TOTAL, 0 AS RESIDENTS_TOTAL, 0 AS PARTY_TOTAL,
eu.DEPT_ID ELSE ( 0 AS OVER_FIFTY_PARTY_TOTAL, 0 AS UNDER_FIFTY_PARTY_TOTAL, COUNT( ID ) AS COMPANY_REPRESENT_TOTAL
SELECT FROM
eugr.GRID_ID meta_epdc_enterprise_info
FROM WHERE DEL_FLAG = 0
meta_epdc_user_grid_relation eugr GROUP BY DEPT_ID
WHERE ) total
eugr.DEL_FLAG = '0' GROUP BY
AND eugr.USER_ID = eu.ID total.GRID_ID
ORDER BY </note>
CREATED_TIME
LIMIT 1
)
END AS GRID_ID
FROM
meta_epdc_user eu
WHERE
eu.DEL_FLAG = '0'
) t
where t.grid_id != ''
GROUP BY t.GRID_ID
) t1
UNION ALL
select DEPT_ID AS GRID_ID,
0 AS USER_TOTAL,
0 AS RESIDENTS_TOTAL,
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
GROUP BY DEPT_ID)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,50 +638,73 @@ 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, SUM(total.OVER_FIFTY_PARTY_TOTAL) AS OVER_FIFTY_PARTY_TOTAL,
SUM( total.OVER_FIFTY_PARTY_TOTAL ) AS OVER_FIFTY_PARTY_TOTAL, 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.OVER_FIFTY_PARTY_TOTAL, t1.PARTY_TOTAL,
(t1.PARTY_TOTAL - t1.OVER_FIFTY_PARTY_TOTAL) AS UNDER_FIFTY_PARTY_TOTAL, t1.OVER_FIFTY_PARTY_TOTAL,
0 AS COMPANY_REPRESENT_TOTAL ( t1.PARTY_TOTAL - t1.OVER_FIFTY_PARTY_TOTAL ) AS UNDER_FIFTY_PARTY_TOTAL,
FROM ( 0 AS COMPANY_REPRESENT_TOTAL
SELECT FROM
t.GRID_ID, COUNT( t.ID ) AS USER_TOTAL, (
SUM( t.PARTY_FLAG = 1 ) AS PARTY_TOTAL,
SUM( t.age >= 50 AND t.PARTY_FLAG = 1 ) AS OVER_FIFTY_PARTY_TOTAL
FROM (
SELECT SELECT
eu.ID, eu.PARTY_FLAG, t.GRID_ID,
IFNULL( TIMESTAMPDIFF( YEAR, eu.BIRTHDAY, CURDATE()), 0 ) AS age, COUNT( t.ID ) AS USER_TOTAL,
CASE WHEN eu.DEPT_ID IS NOT NULL AND eu.DEPT_ID &lt;&gt; 0 THEN eu.DEPT_ID ELSE '' END AS GRID_ID SUM( t.PARTY_FLAG = 1 ) AS PARTY_TOTAL,
SUM( t.age >= 50 AND t.PARTY_FLAG = 1 ) AS OVER_FIFTY_PARTY_TOTAL
FROM FROM
meta_epdc_user eu (
WHERE SELECT
eu.DEL_FLAG = '0' eu.ID,
) t eu.PARTY_FLAG,
WHERE t.grid_id != '' IFNULL( TIMESTAMPDIFF( YEAR, eu.BIRTHDAY, CURDATE( ) ), 0 ) AS age,
GROUP BY t.GRID_ID CASE
) t1 UNION ALL
SELECT WHEN eu.DEPT_ID IS NOT NULL
DEPT_ID AS GRID_ID, 0 AS USER_TOTAL, 0 AS RESIDENTS_TOTAL, 0 AS PARTY_TOTAL, AND eu.DEPT_ID &lt;&gt; 0 THEN
0 AS OVER_FIFTY_PARTY_TOTAL, 0 AS UNDER_FIFTY_PARTY_TOTAL, COUNT( ID ) AS COMPANY_REPRESENT_TOTAL eu.DEPT_ID ELSE (
FROM SELECT
meta_epdc_enterprise_info eugr.GRID_ID
WHERE DEL_FLAG = 0 FROM
GROUP BY DEPT_ID meta_epdc_user_grid_relation eugr
) total WHERE
GROUP BY eugr.DEL_FLAG = '0'
total.GRID_ID</sql> AND eugr.USER_ID = eu.ID
ORDER BY
CREATED_TIME
LIMIT 1
)
END AS GRID_ID
FROM
meta_epdc_user eu
WHERE
eu.DEL_FLAG = '0'
) t
where t.grid_id != ''
GROUP BY t.GRID_ID
) t1
UNION ALL
select DEPT_ID AS GRID_ID,
0 AS USER_TOTAL,
0 AS RESIDENTS_TOTAL,
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
GROUP BY DEPT_ID)total
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