# clickhouse:skip problems with DISTINCT ON
# glaredb:skip — TODO: started raising an error on 2024-05-20, from https://github.com/PRQL/prql/actions/runs/9154902656/job/25198160283:
# ERROR: This feature is not implemented: Unsupported ast node in sqltorel:
# Substring { expr: Identifier(Ident { value: "title", quote_style: None }),
# substring_from: Some(Value(Number("2", false))), substring_for:
# Some(Value(Number("5", false))), special: true }
from tracks
group genre_id (
sort milliseconds
derive {
num = row_number this,
total = count this,
last_val = last track_id,
}
take 10
)
sort {genre_id, milliseconds}
select {track_id, genre_id, num, total, last_val}
filter genre_id >= 22