Обсуждение: Does PostgreSQL support Constant Expression (Alias Name)?

Поиск
Список
Период
Сортировка

Does PostgreSQL support Constant Expression (Alias Name)?

От
Raymond Chui
Дата:
If  a table has columns fname, lname.
I want to do query like

SELECT fname "First Name", lname "Last Name" FROM aTable;

This SELECT statement is fine in Oracle, Sybase and Informix.
But I get an error message in PostgreSQL

Because I want the output like

First Name | Last Name
--------------------------
fn               | ln

instead default like

fname | lname
---------------
fn       | ln

What is the correct way doing this in PostgreSQL?
Thank you very much in advance!



--Raymond


Вложения

Re: Does PostgreSQL support Constant Expression (Alias Name)?

От
"Oliver Elphick"
Дата:
Raymond Chui wrote:
  >This is a multi-part message in MIME format.
  >--------------CDE89E33286CEE4876F664CE
  >Content-Type: text/plain; charset=us-ascii
  >Content-Transfer-Encoding: 7bit
  >
  >If  a table has columns fname, lname.
  >I want to do query like
  >
  >SELECT fname "First Name", lname "Last Name" FROM aTable;

SELECT fname AS "First Name", lname AS "Last Name" FROM aTable;

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "I will lift up mine eyes unto the hills, from whence
      cometh my help. My help cometh from the LORD, which
      made heaven and earth."
                           Psalms 121:1,2



Re: Does PostgreSQL support Constant Expression (Alias Name)?

От
Raymond Chui
Дата:
Thank you very much to all helped me. You save me a lot of time.
(*^_^*)


Вложения