diff --git a/src/queries.zig b/src/queries.zig index e298ea3..a665a58 100644 --- a/src/queries.zig +++ b/src/queries.zig @@ -457,3 +457,18 @@ pub fn loadQuery(entity: EntityType, query_type: QueryTypeEnum) GeneratedQuery { }, }; } + +// I'm pretty sure this query will tell you the number of days a song was played on the same day as a specified song +// The output looked right at least. Can easily be changed into the number of times a song was played on the same day +// as a specified song by removing DISTINCT from the first subquery (which would increase the count if a song was +// played more than once in a day) + +//SELECT COUNT(albumsong), name +//FROM ( +// SELECT DISTINCT scrobbles.albumsong, songs.name, TO_CHAR(scrobbles.datetime, 'YYYY-MM-DD') +// FROM scrobbles +// INNER JOIN albumsongs ON albumsongs.id = scrobbles.albumsong +// INNER JOIN songs ON songs.id = albumsongs.song_id +// WHERE TO_CHAR(datetime,'YYYY-MM-DD') IN ( +// SELECT DISTINCT TO_CHAR(datetime,'YYYY-MM-DD') FROM scrobbles WHERE albumsong = $1 +//)) GROUP BY albumsong, name ORDER BY COUNT(albumsong) DESC, name ASC;