Subquery on line 27 fails to reference table aliases a and b > no such column: a.action > no such column: b.action select action, count(*) as runs, sum(errors) as errors, count(*) filter (where errors > 0) / count(*) * 100 as errors_ptc, avg(length) filter (where errors = 0) as avg_length, max(length) filter (where errors = 0) as max_length, min(length) filter (where errors = 0) as min_length, ( select length from actions as b where b.action = a.action and errors = 0 and created_at between 1739285873236 and 1739287673236 order by length limit 1 offset round( ( select count(*) from actions where action = a.action and errors = 0 and created_at between 1739285873236 and 1739287673236 ) * 0.95 )-1 ) as qtile_95 from actions as a where created_at between 1739285873236 and 1739287673236 group by action;