longzou@hotmail.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