SELECT
(users.created_at::timestamp - invitations.created_at::timestamp) as elapsed,
percentile_disc(0.50)
WITHIN GROUP (ORDER BY elapsed) as median
FROM invitations
join users on users.id = invitations.user_id
Trying to find out the median wait time between the creation of an invitation and the acceptance of it by the user. This code generates an error:
ERROR: column "elapsed" does not exist.
How can I repair it?