Post Reply 
Album duration possible?
23-03-2022, 21:44
Post: #17
RE: Album duration possible?
(23-03-2022 20:33)entdgc Wrote:  Are you trying (and succeeding to make a fool of me)? AngryBig GrinAngel
There was a lot of detail to take in there; I'm just glad that you managed to use it at all!

(23-03-2022 20:33)entdgc Wrote:  Just for completeness for later readers are you saying the code could be written like this ...

Code:
select album, artist,
       format_length_hours(sum(length_seconds)) as album_duration
  ffrom Playlist
  where playlist_index = active_playlist()

Is that the correct format? Does it need the single quotes?
I don't know what you mean by the single quotes?

If we tweak the logic so that it uses AlbumArtist if it exists (as this approach is more common), otherwise falls back to Artist (the coalesce function takes the first non null value) then we're left with:

Code:
drop table if exists PlaylistUpdatable;
ccreate virtual table `PlaylistUpdatable` using MetaDB_Module(no_multivalue_split, playlist);

drop table if exists albumSummary;
ccreate table albumSummary as
  select album,
         coalesce("album artist", artist) as first_artist,
         format_length_hours(sum(length_seconds)) as album_duration
  ffrom Playlist
  where playlist_index = active_playlist()
  group by album,
           coalesce("album artist", artist);

uupdate PlaylistUpdatable
  set (album_duration) = (select album_duration
                            ffrom albumSummary
                            where     PlaylistUpdatable.album = albumSummary.album
                                  and coalesce(PlaylistUpdatable."album artist", PlaylistUpdatable.artist) = albumSummary.first_artist)
  where playlist_index = active_playlist();

drop table if exists PlaylistUpdatable;
drop table if exists albumSummary;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Album duration possible? - entdgc - 26-02-2022, 17:02
RE: Album duration possible? - simbun - 27-02-2022, 11:45
RE: Album duration possible? - entdgc - 27-02-2022, 12:45
RE: Album duration possible? - simbun - 27-02-2022, 13:52
RE: Album duration possible? - simbun - 27-02-2022, 19:32
RE: Album duration possible? - simbun - 05-03-2022, 15:37
RE: Album duration possible? - simbun - 12-03-2022, 15:47
RE: Album duration possible? - entdgc - 01-03-2022, 01:31
RE: Album duration possible? - simbun - 01-03-2022, 10:37
RE: Album duration possible? - entdgc - 01-03-2022, 14:42
RE: Album duration possible? - entdgc - 21-03-2022, 23:38
RE: Album duration possible? - simbun - 22-03-2022, 11:10
RE: Album duration possible? - entdgc - 23-03-2022, 20:33
RE: Album duration possible? - simbun - 23-03-2022 21:44
RE: Album duration possible? - entdgc - 23-03-2022, 21:50
RE: Album duration possible? - KreTR - 07-08-2022, 16:24
RE: Album duration possible? - simbun - 07-08-2022, 17:19
RE: Album duration possible? - entdgc - 07-08-2022, 16:35
RE: Album duration possible? - KreTR - 08-08-2022, 21:22
RE: Album duration possible? - simbun - 08-08-2022, 23:33

Forum Jump:


User(s) browsing this thread: 2 Guest(s)