I'm new to PostgreSQL, so maybe my question is unconvinced. But what I want is to put the result of one query into a variable and then used it again in another query. I run my query inside pgAdmin4, Below is my query:
Also I tried those solution1, solution2 without achieving my goal.
WITH vars AS (
(select count(*) from employee) AS vars_id
)
select
*
from
employee
where
id=vars.vars_id;
The error is:
ERROR: syntax error at or near "AS"
LINE 2: (select count(*) from employee) AS vars_id
^
SQL state: 42601
Character: 49