From: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: unnest in SELECT |
Date: | 2011-05-21 06:58:49 |
Message-ID: | 20110521065849.GA5587@tux |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Karl Koster <klkoster(at)optonline(dot)net> wrote:
> I have a couple of questions regarding unnest.
>
> 1) If I issue a select statement "select unnest(vector1) as v from
> some_table", I cannot seem to use the column alias v in a WHERE or
> HAVING clause. I can use it in an ORDER BY or GROUP by clause. Is this
> the way it is supposed to work?
Yes. It's the same as:
test=# select 1 as a where a = 2;
ERROR: column "a" does not exist
LINE 1: select 1 as a where a = 2;
in other words: the column a is unknown for the where-condition at this
time.
>
> 2) If I issue a select statement "select unnest(vector1) as v1,
> unnest(vector2) as v2 from some_table" and vector1 has a length of 3 and
> vector2 has a length of 4, the result set will have 12 rows with the
> data of vector1 repeating 4 times and vector2 repeating 3 times.
Yeah, it's a cross-join.
Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
From | Date | Subject | |
---|---|---|---|
Next Message | Gavin Baumanis | 2011-05-21 23:10:17 | Re: Which version of PostgreSQL should I use. |
Previous Message | Karl Koster | 2011-05-20 19:45:17 | unnest in SELECT |