SELECT alias = expr - Non-Standard Alias - SQL Server to PostgreSQL Migration

In SQL Server you can use SELECT alias = expression syntax to define the column alias (do not confuse with SELECT @variable = expression variable assignment syntax).

In PostgreSQL you have to use standard SELECT expression [AS] alias syntax to define the column aliases.

SQL Server:

  -- a and b are aliases
  SELECT a = LEN('abc'), b = 'abc';
  #  a     b
  # --------
  #  3     abc

PostgreSQL:

  -- SQL Server syntax is not supported 
  SELECT a = LEN('abc'), b = 'abc';
  # ERROR:  column "a" does not exist
 
  -- a and b are aliases using SQL standard syntax
  SELECT LENGTH('abc') AS a, 'abc' b;
  #  a     b
  # --------
  #  3     abc

For more information, see SQL Server to PostgreSQL Migration.