Advertisement
dimuska139

Untitled

Oct 18th, 2021
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select
  2.        locale,
  3.        d::date,
  4.        total
  5.    from
  6.        generate_series(current_date - interval '1 months', current_date, interval '1 day') as d
  7.        join lateral (
  8.            select
  9.                l.name as locale,
  10.                count(*) as total
  11.            from content c
  12.             inner join films f on f.content_id =  c.id
  13.             left join films_info fi on fi.film_id = f.id
  14.             inner join locales l on l.id = fi.locale_id
  15.             where c.content_type = 'movie' and c.created_at < d
  16.                 group by l.name) s on true
  17.    order by
  18.        d desc,
  19.        locale asc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement