ORDER BY (SUM(case when OPERATION_TYPE = 1 then IFNULL(points,0) else 0 end) - SUM(case when OPERATION_TYPE = 0 then IFNULL(points,0) else 0 end)) DESC
) tab ,(select @i:=0) t1
) tab ,(select @i:=0) t1
GROUP BY tab.points
ORDER BY tab.points DESC
) userRanking
) userRanking
WHERE userRanking.userId = #{userId}
WHERE userRanking.userId = #{userId}
</select>
</select>
@ -165,18 +163,21 @@
COUNT(1)
COUNT(1)
FROM(
FROM(
SELECT
SELECT
USER_ID,
p.points
SUM(case when OPERATION_TYPE = 0 then IFNULL(points,0) else 0 end) totalPointsDeducted,
FROM(
SUM(case when OPERATION_TYPE = 1 then IFNULL(points,0) else 0 end) totalPointsAdd
SELECT
FROM epdc_points_logs
USER_ID,
WHERE DEL_FLAG = 0
(SUM(case when OPERATION_TYPE = 1 then IFNULL(points,0) else 0 end) - SUM(case when OPERATION_TYPE = 0 then IFNULL(points,0) else 0 end)) points
<iftest="rankingType != null and rankingType == 0">
FROM epdc_points_logs
AND YEARWEEK(date_format(OPERATION_TIME,'%Y-%m-%d')) = YEARWEEK(now())
WHERE DEL_FLAG = 0
</if>
<iftest="rankingType != null and rankingType == 0">
<iftest="rankingType != null and rankingType == 1">
AND YEARWEEK(date_format(OPERATION_TIME,'%Y-%m-%d')) = YEARWEEK(now())