1. 程式人生 > >CASE types character varying and numeric cannot be matched

CASE types character varying and numeric cannot be matched

EXPLAIN SELECT
se.enroll_number,
s.student_name,
CASE
WHEN pay.pay_method = '支付高校' THEN
0
ELSE
pay.sum_pay
END AS sum_pay,
 concat (
'支付高校',
CASE
WHEN pay.pay_method != '支付高校' THEN
''
ELSE
'' || pay.sum_pay
END
)
AS remark,
 pay.sum_deduct
FROM
(
SELECT
student_id,
pay_method,
SUM (pay_money) AS sum_pay,
SUM (channel_deduct) AS sum_deduct

FROM
payment_detail
WHERE
college_settlement_id = 28
GROUP BY
student_id,
pay_method
) AS pay
LEFT JOIN student AS s ON pay.student_id = s.student_id
LEFT JOIN student_enroll AS se ON pay.student_id = se.student_id