I am trying to convert a column in a database into a timestamp format, then I want to see the number of counts for each year.
I have:
SELECT
(column_name::date), count(*)
EXTRACT(YEAR FROM column_name)
FROM table
GROUP BY column_name;
'I get an error message that says no function matches the given name and argument types. You might need to add explicit type casts.'
Is extract the wrong function?
You probably want something like this if column_name
is timestamp
search for EXTRACT documentation
SELECT
EXTRACT(YEAR FROM column_name), count(*)
FROM table
GROUP BY EXTRACT(YEAR FROM column_name);
if column_name
is string you need to_timestamp() function
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.