Re: SELECT returnig a constant

From: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
To: "Ray O'Donnell" <ray(at)rodonnell(dot)ie>
Cc: stan <stanb(at)panix(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: SELECT returnig a constant
Date: 2019-10-15 14:25:00
Message-ID: CAEzk6fcLYY2OKErR+i0CMKDUVnmHMbpBm8kWFycWTCRA==YFzw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 15 Oct 2019 at 14:35, Ray O'Donnell <ray(at)rodonnell(dot)ie> wrote:
>
> On 15/10/2019 14:28, stan wrote:
> > I used to be able to return a constant value in a SELECT statement in
> > ORACLE. I need to populate a table for testing, and I was going to do so
> > like this:
> >
> > SELECT
> > employee.id ,
> > project.proj_no ,
> > work_type.type ,
> > 'rate' 1
> > FROM employee
> > CROSS JOIN project
> > CROSS JOIN work_type;
> >
> > This statement works correctly, till I add the last " 'rate' 1 line, then it
> > returns a syntax error.
>
> I don't think you can use a number as a column name. Give it a different
> name and it should work:

Well you can but only if you quote the column alias

SELECT
employee.id ,
project.proj_no ,
work_type.type ,
'rate' "1"
FROM employee
CROSS JOIN project
CROSS JOIN work_type;

but I really wouldn't recommend it. That way madness lies.

Geoff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Gierth 2019-10-15 14:28:40 Re: Inserting multiple rows wtih a SELECt in the values clause
Previous Message stan 2019-10-15 13:52:24 Inserting multiple rows wtih a SELECt in the values clause