From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | longzou(at)hotmail(dot)com |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #13486: How can I sort unnest results? |
Date: | 2015-07-06 03:05:35 |
Message-ID: | 26539.1436151935@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
longzou(at)hotmail(dot)com writes:
> I have a query that using the unnest function. But I don't know how to sort
> the result.
This isn't a bug, and the bug tool is not an appropriate way to ask usage
questions.
> For example:
> select * from unnest(array[1,2,3,4,5,6], array[10,8,3,6,8,2], array['ab',
> 'dd','','dd','st']);
> The result will have three columns and those name are 'unnest'. So, if I use
> unnest as the order by cause, it will raise an error:
> ERROR: ORDER BY "unnest" is ambiguous.
Assign distinct column aliases, for example
# select * from unnest(array[1,2,3,4,5,6], array[10,8,3,6,8,2], array['ab',
'dd','','dd','st']) as u(a,b,c);
a | b | c
---+----+----
1 | 10 | ab
2 | 8 | dd
3 | 3 |
4 | 6 | dd
5 | 8 | st
6 | 2 |
(6 rows)
Now you can order on whichever column you want.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Fabien COELHO | 2015-07-06 05:36:53 | Re: BUG #12379: pgbench should hint to pgbench -i |
Previous Message | Thomas Munro | 2015-07-06 02:43:38 | Re: BUG #13487: GetBufferFromRing code bug |