-- 验证：AVG 是否忽略 NULL
-- 预期：如果忽略 NULL，avg_with_null = 2.0（只算 1,2,3）
--       如果不忽略，avg_with_null = 1.5（sum=6, count=4）
SELECT  AVG(val) AS avg_all
        ,AVG(CASE WHEN val <= 2 THEN val END) AS avg_case_null
        ,COUNT(1) AS cnt_all
        ,COUNT(CASE WHEN val <= 2 THEN val END) AS cnt_case
FROM (
    SELECT 1 AS val
    UNION ALL SELECT 2
    UNION ALL SELECT 3
    UNION ALL SELECT 4
) t
;
