数据只有出生年份列,标记为
year_birth
。
我添加了一个年龄列,但现在我想向此列添加值,以通过减去当前年份中的值来显示年龄
year_birth
列中的值。
“出生年份”“年龄”
1970
1961
1958
1967
1989
1958
1954
1967
1954
1954
此查询返回语法错误
-- Update Age column
update marketing_data
set age = DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),year_birth)), '%Y')
+ 0
ERROR: function datediff(timestamp with time zone, integer) does not exist
LINE 4: set age = DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),year_birth)),...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 77