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
[ID]=fileid
is a boolean expression, returningTRUE
if the column[ID]
value is equal to the columnfileid
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:
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
or