84 | | select g.genre_type, extract(year from m.airing_date), count(m.movie_id) as movie_count from genres as g |
85 | | join movie_genres as mg on mg.genre_id = g.genre_id |
86 | | join movies as m on m.movie_id = mg.movie_id |
87 | | group by g.genre_type, extract(year from m.airing_date) |
88 | | order by movie_count desc |
| 84 | select g.genre_type, |
| 85 | count(distinct d) + count(distinct r) as discussions_replies_count |
| 86 | from genres g |
| 87 | join movie_genres mg on mg.genre_id = g.genre_id |
| 88 | join movies m on m.movie_id = mg.movie_id |
| 89 | join discussions d on d.movie_id = m.movie_id and d.date between current_date - interval '14 days' and current_date |
| 90 | left join replies r on r.discussion_id = d.discussion_id and r.date between current_date - interval '14 days' and current_date |
| 91 | group by g.genre_id |
| 92 | order by count(distinct d) + count(distinct r) desc |
| 93 | limit 1 |