Browse Source

居民排行sql语句修改

dev
yujintao 6 years ago
parent
commit
471ea1718c
  1. 34
      esua-epdc/epdc-module/epdc-analysis/epdc-analysis-server/src/main/resources/mapper/user/UserAnalysisDao.xml

34
esua-epdc/epdc-module/epdc-analysis/epdc-analysis-server/src/main/resources/mapper/user/UserAnalysisDao.xml

@ -9,8 +9,8 @@
t1.userCount - t1.partyMemberCount AS residentCount, t1.userCount - t1.partyMemberCount AS residentCount,
t1.oldCount / t1.userCount oldPercent, t1.oldCount / t1.userCount oldPercent,
t1.youngCount / t1.userCount youngPercent t1.youngCount / t1.userCount youngPercent
FROM FROM (
( SELECT SELECT
t.streetName, t.streetId, t.streetName, t.streetId,
COUNT( t.userId ) userCount, COUNT( t.userId ) userCount,
count( t.SEX = '1' OR NULL ) maleCount, count( t.SEX = '1' OR NULL ) maleCount,
@ -42,45 +42,29 @@
</if> </if>
</otherwise> </otherwise>
</choose> </choose>
/*待补充按时间筛选*/
<if test="startTime != null and endTime != null and endTime != ''"> <if test="startTime != null and endTime != null and endTime != ''">
AND uu.CREATED_TIME BETWEEN #{startTime} AND uu.CREATED_TIME BETWEEN #{startTime} AND #{endTime}
AND #{endTime}
</if> </if>
AND ad.id IS NOT NULL AND ad.id IS NOT NULL
) t ) t
) t1
<choose> <choose>
<when test='category != null and category == "0"'> <when test='category != null and category == "0"'>
where order by t1.oldCount desc
t.age>=50
GROUP BY t.streetId
order by COUNT( t.age > 50 OR NULL ) desc
</when> </when>
<when test='category != null and category == "1"'> <when test='category != null and category == "1"'>
where order by t1.youngCount desc
t.age &lt; 50
GROUP BY t.streetId
order by COUNT( ( t.age &lt;= 50 AND t.age > 0 ) OR NULL ) desc
</when> </when>
<when test='category != null and category == "2"'> <when test='category != null and category == "2"'>
where order by t1.oldCount asc
t.age>=50
GROUP BY t.streetId
order by COUNT( t.age > 50 OR NULL ) asc
</when> </when>
<when test='category != null and category == "3"'> <when test='category != null and category == "3"'>
where order by t1.youngCount asc
t.age &lt; 50
GROUP BY t.streetId
order by COUNT( t.age > 50 OR NULL ) asc
</when> </when>
<otherwise> <otherwise>
GROUP BY t.streetId GROUP BY t1.streetId
</otherwise> </otherwise>
</choose> </choose>
) t1
/*待补充排序功能 order by t1.oldCount asc */
</select> </select>
<select id="selectListPartyAuthFailureCountByStreetId" <select id="selectListPartyAuthFailureCountByStreetId"

Loading…
Cancel
Save