Back to Code Snippets


Replacing one a column in a select * with an expression under a different nameSQL

Execute this SQL

-- * EXCLUDE plus any additional expression does the trick
SELECT * EXCLUDE (valid_from),  -- valid_from used in computation
       year(valid_from) AS year -- A new expression
FROM prices
 -- Note that the new expression can be referred to in the WHERE clause
WHERE year BETWEEN 2019 AND 2020;

Copy code

Michael Simons

Copy code

Expand

Share link