17 lines
No EOL
383 B
Text
17 lines
No EOL
383 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; |