SQL 修改
This commit is contained in:
parent
bcb3982b2e
commit
ae3952a03b
|
|
@ -127,17 +127,13 @@
|
|||
MAX(fsp."eva_month") as evaMonth,
|
||||
MAX(fsp."eva_score") AS evaScore,
|
||||
COUNT(bs."sub_name") as proNum,
|
||||
SUM(fsp."eva_score") / COUNT(bs."sub_name") as evaScore,
|
||||
case
|
||||
WHEN
|
||||
COUNT(bm."sub_name") = 0 THEN 0
|
||||
ELSE SUM(fsp."eva_score") / COUNT(bs."sub_name")
|
||||
END as evaScore
|
||||
case
|
||||
WHEN COUNT(bm."sub_name") = 0 THEN 0
|
||||
WHEN ROUND(SUM(fsp."eva_score") / NULLIF(COUNT(bm."sub_name"), 0), 2) > 90 THEN 1
|
||||
when ROUND(SUM(fsp."eva_score") / NULLIF(COUNT(bm."sub_name"), 0), 2) > 80 THEN 2
|
||||
when ROUND(SUM(fsp."eva_score") / NULLIF(COUNT(bm."sub_name"), 0), 2) > 60 THEN 3
|
||||
when ROUND(SUM(fsp."eva_score") / NULLIF(COUNT(bm."sub_name"), 0), 2) < 61 THEN 4
|
||||
WHEN COUNT(bs."sub_name") = 0 THEN 0
|
||||
WHEN ROUND(SUM(fsp."eva_score") / NULLIF(COUNT(bs."sub_name"), 0), 2) > 90 THEN 1
|
||||
when ROUND(SUM(fsp."eva_score") / NULLIF(COUNT(bs."sub_name"), 0), 2) > 80 THEN 2
|
||||
when ROUND(SUM(fsp."eva_score") / NULLIF(COUNT(bs."sub_name"), 0), 2) > 60 THEN 3
|
||||
when ROUND(SUM(fsp."eva_score") / NULLIF(COUNT(bs."sub_name"), 0), 2) < 61 THEN 4
|
||||
else 0
|
||||
End as status
|
||||
FROM
|
||||
|
|
@ -147,12 +143,30 @@
|
|||
AND bs."id" IS NOT NULL
|
||||
LEFT JOIN "ynrealname"."fbeva_sub_project" fsp ON fsp."contract_id" = bsc."id"
|
||||
WHERE
|
||||
bs."id" IS NOT NULL
|
||||
AND fsp."eva_month" IS NOT NULL
|
||||
WHERE
|
||||
bsc."is_active" = '1'
|
||||
AND td."value" = #{params.month} and fcpe."eva_date" is not null
|
||||
<if test="params != null and params != ''">
|
||||
<if test="params.proId != null and params.proId != ''">
|
||||
AND bp."id" =#{params.proId}
|
||||
</if>
|
||||
<if test="params.subName != null and params.subName != ''">
|
||||
AND bsc."contract_name" LIKE concat('%', #{params.subName}, '%')
|
||||
</if>
|
||||
|
||||
</if>
|
||||
GROUP BY
|
||||
bs."sub_name"
|
||||
<if test="params.status != null and params.status != '' ">
|
||||
having status = #{params.status}
|
||||
HAVING
|
||||
CASE
|
||||
WHEN COUNT(bs."sub_name") = 0 THEN 0
|
||||
WHEN ROUND(SUM(fsp."eva_score") / COUNT(bs."sub_name"), 2) > 90 THEN 1
|
||||
WHEN ROUND(SUM(fsp."eva_score") / COUNT(bs."sub_name"), 2) > 80 THEN 2
|
||||
WHEN ROUND(SUM(fsp."eva_score") / COUNT(bs."sub_name"), 2) > 60 THEN 3
|
||||
WHEN ROUND(SUM(fsp."eva_score") / COUNT(bs."sub_name"), 2) < 61 THEN 4
|
||||
ELSE 0
|
||||
END = #{params.status}
|
||||
</if>
|
||||
<if test="offset != null and offset >= 0 and limit != null and limit >= 0">
|
||||
OFFSET #{offset} ROWS FETCH NEXT #{limit} ROWS ONLY
|
||||
|
|
|
|||
Loading…
Reference in New Issue