- 先看字符转数字有以下方法:
方法一:SELECT CAST('123' AS SIGNED);
方法二:SELECT CONVERT('123',SIGNED);
方法三:SELECT '123'+0;
- 然后分组求和统计:
SELECT
name,
sum(
CASE
WHEN age IS NULL THEN
'0'
ELSE
age + 0
END
) AS age_sum
FROM
user
GROUP BY
name
网友评论