Re: SELECT returnig a constant - Mailing list pgsql-general

From Ray O'Donnell
Subject Re: SELECT returnig a constant
Date
Msg-id 1071f28a-c7a8-1b51-cd88-803a331158aa@rodonnell.ie
Whole thread Raw
In response to SELECT returnig a constant  (stan <stanb@panix.com>)
Responses Re: SELECT returnig a constant
List pgsql-general
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:

SELECT .... , 'rate' my_constant_name FROM ...

Ray.


-- 
Raymond O'Donnell // Galway // Ireland
ray@rodonnell.ie



pgsql-general by date:

Previous
From: stan
Date:
Subject: SOLVED Re: SELECT returnig a constant
Next
From: Tomas Vondra
Date:
Subject: Re: timescaleDB & WAL replication