Postgres的CASE语法示例

SELECT
    a.city,a.staff_name,
    (
CASE
    
    WHEN a.basic_pay > b.top_pensions_insurance THEN
    b.top_pensions_insurance * b.company_pensions_insurance_pay 
    WHEN a.basic_pay < b.top_pensions_insurance THEN
    a.basic_pay * b.company_pensions_insurance_pay 
END 
    ) AS company_pensions 
FROM
    social_security_detail a
LEFT JOIN social_security_contrib_ratio b ON a.city = b.city;

你可能感兴趣的:(Postgres的CASE语法示例)