Renaming columns with AS
Column names in a database are written for computers: list_price, payment_terms_days. When you
share a result, clearer headings help. AS gives a column a new name in the result. This is called
an alias:
SELECT sku AS product_code, name AS product_name
FROM productsThe table itself doesn't change. The alias only applies to this result.
Names with spaces or capitals
An alias with spaces, capitals or symbols needs double quotes:
SELECT name AS "Product", list_price AS "Price (£)"
FROM productsOther databases: MySQL also accepts backticks (
`Price (£)`) and SQL Server accepts square brackets ([Price (£)]). Double quotes are the SQL standard, and DuckDB, PostgreSQL and BigQuery use them.
Text values, like 'Leeds', always use single quotes. Double quotes are for names.