Reputation: 13
I have a query about such a structure:
SELECT distinct
...,
...,
(CASE WHEN
(select ... from ... where ...)
IS NULL
THEN 'Site' ||LOWER((
select ... from ... where ... and ...))
ELSE
(select ...
from ...
where ...)
END) as importantResult
FROM
...
WHERE
...
And now i need to filter only one value from result of importantResult. I cannot specify this in WHERE.
What i should do?
Upvotes: 1
Views: 116
Reputation: 142705
Use "this" as a CTE; then filter.
For example:
with temp as
(select distinct ... <your query goes here>
... as importantResult
from ...
)
select whatever
from temp
where importantResult = some_value
Upvotes: 4