postgresql - Extracting year from a date timestamp in SQL -


i trying convert column in database timestamp format, want see number of counts each year.

i have:

select     (column_name::date), count(*)     extract(year column_name) table group column_name; 

'i error message says no function matches given name , argument types. might need add explicit type casts.'

is extract wrong function?

you want if column_name timestamp

search extract documentation

select     extract(year column_name), count(*)         table group extract(year column_name); 

if column_name string need to_timestamp() function


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -