"pq: could not find pathkey item to sort" for time interval <24 hours

Hi,
I get the error “pq: could not find pathkey item to sort”
for the following query if the selected time interval is less than 24 hours.
It works when selecting two days.
SELECT
$__timeGroupAlias(s1.wd_time,20m), percentile_cont(0.25) within group(order by (s1.“dB” - s2.“dB”)) as “”“lower quartile”""
FROM spots s1
join spots s2 on s1.wd_time = s2.wd_time
and s1.“CallSign” = s2.“CallSign”
and s1.“Reporter” = ‘$receiver_A’ and s2.“Reporter” = ‘$receiver_B’
and s1.wd_band=’$band_m’ and s2.wd_band=’band_m' WHERE __timeFilter(s1.wd_time)
GROUP BY 1
ORDER BY 1

Help welcome.
Gwyn