sqlpostgresqlstring-constant

How to add a string literal as one selected column for select queries?


I want to have query like below

select "RETRY" as code , name from process ;

then the results are

code |  name
_____________

RETRY  PX1
RETRY  PX1
RETRY  PX3
RETRY  PX4
RETRY  PX5

I want to add one string literal as column for all rows returned by select query. I am trying this in PostgreSQL, but getting the following error:

SQL Error [42703]: ERROR: column "RETRY" does not exist
  Position: 8

yny idea how to do this in a PostgreSQL select query?


Solution

  • double quote refers column name of that table thats why you are getting error you have to use single quote

    select 'RETRY' as code , name from process ;