我正在尝试查找出生日期在 1980 年到 1996 年之间的用户的百分比。
我找不到怎么做:
SELECT Sum
(WHEN userBirthDate BETWEEN '1980/01/01' AND '1996/12/31'
THEN 1 ELSE 0 END) * 100 / Count(userID) as total
FROM user
mysql 返回的错误是语法:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHEN userBirthDate BETWEEN '1980/01/01' AND '1996/12/31' THEN 1 ELSE 0)' at line 1
我该怎么做?
先感谢您