ORDER BY in UNION in postgres 7.3.9 -
08-05-2008
, 02:44 AM
"SELECT a.*, m.mailbox_name FROM addresses a, mailboxes m,
link_mailbox_addresses lma "
+ "WHERE NOT temp_address AND NOT delete AND a.address_ref > 0 AND
protocol <> ? "
+ "AND a.address_ref = lma.address_ref AND lma.mailbox_ref =
m.mailbox_ref "
+ "UNION SELECT *, '' FROM addresses WHERE address_ref NOT IN "
+ "(SELECT address_ref from link_mailbox_addresses) "
+ "AND NOT temp_address AND NOT delete AND address_ref > 0 AND protocol
<> ? "
+ "ORDER BY site_name ASC, recipient_name ASC");
when last line is replaced with
"ORDER BY UPPER(site_name) ASC, recipient_name ASC"
I get ( postgres 7.3.9) ERROR: ORDER BY on a UNION/INTERSECT/EXCEPT
result must be on one of the result columns
which I don't understand. Can someone explain?
Thank you very much !!
regards,
Robert |