16 lines
367 B
Text
16 lines
367 B
Text
CREATE OR REPLACE VIEW month_genres AS
|
|
SELECT
|
|
ol.genre_name,
|
|
ol.genre_url,
|
|
COUNT(*) AS plays,
|
|
json_build_object('alt', ol.genre_name, 'subtext', CONCAT(COUNT(*), ' plays')) AS grid
|
|
FROM
|
|
optimized_listens ol
|
|
WHERE
|
|
TO_TIMESTAMP(ol.listened_at) >= NOW() - INTERVAL '30 days'
|
|
GROUP BY
|
|
ol.genre_name,
|
|
ol.genre_url
|
|
ORDER BY
|
|
plays DESC;
|
|
|