Suppose I have the following table in Postgres:
CREATE TABLE movies (
id serial primary key,
title text,
actor_ids bigint[]
)
How can I get the number of movies each actor has starred in? I should be printed like this:
actor_id | count
----------------
53 | 4
92 | 13
132 | 1
1221 | 2
The actor_ids column is an array that contains the ids of the actors starring in the movie.