Last active
August 5, 2024 13:02
-
-
Save snth/83671aa81c73e33872a0da1f0bb898fb to your computer and use it in GitHub Desktop.
jazzTracks example in PRQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Try this for yourself at: https://prql-lang.org/playground/ | |
let arr_agg = func x -> s"array_agg({x})" | |
let jazzTracks = ( | |
from t=tracks | |
join g=genres (==genre_id && g.name=="Jazz") | |
select {t.*, genre=g.name} | |
) | |
from a=albums | |
join s=artists (==artist_id) | |
join j=jazzTracks (j.album_id==a.album_id) | |
group {AlbumTitle = a.title, Artist = s.name} ( | |
aggregate { | |
JazzTracks=(arr_agg f"{{Name='{j.name}',UnitPrice={j.unit_price}}}") | |
} | |
) | |
sort Artist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment