skip to Main Content

I found that aliasing using the '=' format is not working in AWS Redshift. Is there any possible way to resolve this without changing on existing query?

In SQL Server:

select fileid AS ID from tableA     -- Working 
select [ID] = fileid from tableA    -- Working

In AWS Redshift:

select fileid AS ID from tableA    -- Working 
select [ID] = fileid from tableA   -- Fails, will return ERROR: column id does not exist in table A.

2

Answers


  1. [ID]=fileid is a boolean expression, returning TRUE if the column [ID] value is equal to the column fileid value. (ISO/ANSI SQL-2023, optional feature T031, BOOLEAN data type.)

    But you have no column [ID], hence the column id does not exist error.

    Conclusion, do this the ANSI/ISO SQL way:

    select fileid AS ID from tableA 
    
    Login or Signup to reply.
  2. AWS Redshift is based on PostgreSQL and does not support this aliasing syntax.
    Use the ‘as’ keyword or a simple space between the column name and its alias.

    Like these

    select fileid AS ID from tableA;
    

    or

    select fileid ID from tableA;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search