我正在尝试根据最近的日期计算年龄,但是当我使用MAX函数时,它仍然会返回所有日期
SELECT
birth_date,
sign_date,
datediff(year, birth_date, Max(sign_date) -
CASE
WHEN
Datepart (dayofyear, birth_date) > Datepart(dayofyear, sign_date)
THEN
1
ELSE
0
from
customer_info inf
INNER JOIN
table2 a
ON inf.id = a.id)
GROUP BY
inf.birth_date, a.sign_date