I'm new to SQL and trying to do a certain query in which I need two subqueries. I have to give them aliases, but when I do it says:
ERROR: syntax error at or near "as"
But I don't see anything wrong in the syntax. I'm having a lot of trouble with this kind of queries and I don't find much information or examples. Would you help me?
Select
...
from
turno,
(select * from
(
select
...
from
accion
where
accion.tipo = 4 or accion.tipo = 5
) as part1
union
(
select
...
from
accion
where
accion.tipo <> 4 and accion.tipo <> 5
) as part2
) as accion
where
...
;
Thanks a lot.