"ERROR: column "a" does not exist" when referencing column alias
3
votes
3
answers
12939
views
I am attempting to retrieve either a null or boolean value from a query. Here is my query:
SELECT EXISTS (SELECT 1 FROM employee
where add_uuid = '7e53fa47-ade3-4e94-8efd-b25f998b09c6') AS a,
CASE WHEN a = false then null
ELSE (SELECT exists (SELECT 1 FROM employee
where add_uuid = '7e53fa47-ade3-4e94-8efd-b25f998b09c6'
and is_active = true
)
)
END
Results in:
> SQL Error : ERROR: column "a" does not exist
Despite experimenting with multiple options, I am still unable to achieve the desired outcome.
Asked by Aamir
(133 rep)
Jan 18, 2023, 05:24 AM
Last activity: Nov 21, 2024, 05:08 PM
Last activity: Nov 21, 2024, 05:08 PM