| 1 | -- The saga of the transfer that needed the most tries: every step, how it |
| 2 | -- went, and when. Each retry waits about twice as long as the one before. |
| 3 | SELECT step, outcome, left(detail, 52) AS detail, created_at::time(0) AS at |
| 4 | FROM transfer_steps |
| 5 | WHERE transfer_id = ( |
| 6 | SELECT transfer_id FROM transfer_steps WHERE outcome = 'failed' |
| 7 | GROUP BY transfer_id ORDER BY count(*) DESC, max(id) DESC LIMIT 1 |
| 8 | ) |
| 9 | ORDER BY id; |