Question about SELECT and ORDER BY - Mailing list pgsql-sql

From Vladimir Terziev
Subject Question about SELECT and ORDER BY
Date
Msg-id 200002031434.QAA01945@lorna.digsys.bg
Whole thread Raw
Responses Re: [SQL] Question about SELECT and ORDER BY  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
   Hi,


I have two tables:
  table1 (attr1 text, attr2 int4)
  table2 (attr1 text, attr3 int4, attr4 bool)

I have a query:
  SELECT table1.attr1 AS ALIAS, attr2 from table1 UNION ALL  SELECT table2.attr1, attr3 from table2 ORDER BY ALIAS;

I that syntax all is OK.
I want to have a result from ORDER BY length(ALIAS), but this is imposible.

When ORDER BY clause is in format ORDER BY length(attr1), the result is not 
ORDERED BY length of attr1.

What can I do? Are anybody have an idea?
Vladimir



pgsql-sql by date:

Previous
From: "Mark Hollomon"
Date:
Subject: Re: [HACKERS] Re: [SQL] Proposed Changes to PostgreSQL
Next
From: Mark Volpe
Date:
Subject: Re: [SQL] Question about SELECT and ORDER BY