In SQL, I'd use something like this:

```
SELECT year(created_at)
FROM videos
GROUP BY year(created_at)

```

How can I run this query with Rails?

I've tried this:

```
Video.all.group_by { |m| m.created_at.year }

```

... but this will return ALL my records grouped by the corresponding years, which is not entirely bad, except it's returning hundreds of records, when I only need to know the years.

Any pointers?

In case you're wondering I'm using Rails 5.1.5 and MariaDB (10.2.14-MariaDB-10.2.14+maria~xenial-log).