Weird behaviour

Moderator: NorbertKrupa

Post Reply
borka66
Newbie
Newbie
Posts: 6
Joined: Mon Mar 23, 2015 1:21 pm

Weird behaviour

Post by borka66 » Wed May 06, 2015 3:34 pm

Hi,
Can somebody explain why this throws an error
select x, sum(y)
from (
select 1 as x, (select 2 from dual) as y from dual
) a
group by x;

ERROR 4818: Subqueries in the SELECT or ORDER BY are not supported if the subquery is not part of the GROUP BY
and this one not?
select x, sum(y)
from (
select 1 as x, (select 2 from dual) as y from dual
union all select 0, 0 from dual where 1 = 2
) a
group by x;
x | sum
---+-----
1 | 2
(1 row)
This is pretty interesting if I may rely on this workaround.
Vertica v7.0.1-0.
10x!

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Weird behaviour

Post by JimKnicely » Wed May 06, 2015 6:44 pm

Try:

Code: Select all

select x, sum(y)
from (
select 1 as x, (select 2 from dual) as y from dual order by 1
) a
group by x;
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

borka66
Newbie
Newbie
Posts: 6
Joined: Mon Mar 23, 2015 1:21 pm

Re: Weird behaviour

Post by borka66 » Sun May 10, 2015 7:41 am

I like your soltion. Much easier to code.
Could you explain why these workarounds solve the error?

Post Reply

Return to “Vertica SQL”