I have a table with several hundred records, each one containing a datetime column. What is the most efficient way to find the distinct years from that datetime field?
I have a table with several hundred records, each one containing a datetime column.
Share
Using Ruby (this would require loading all the records, though):
Using SQL (this example is for PostgreSQL, I can update it with your specific database):