A finance analyst is building a P&L export for the board deck. The output must contain a column named exactly Net Revenue — two words, with a space, capital N and capital R. Net revenue is gross revenue of $8,500 minus $1,200 in returns.
Write a query that returns net revenue in a column with that exact name.
Output:
- A single row with one column named exactly
Net Revenue. To preserve the space and the case, the alias must be wrapped in double quotes:AS "Net Revenue".
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
8500 - 1200 AS "Net Revenue" The shape
The double quotes around "Net Revenue" are what preserve the space and the capital letters in the column header. Without them, the alias is illegal as written.
Clause by clause
SELECT 8500 - 1200evaluates the subtraction and returns7300— gross revenue minus returns. Both operands are integer literals, so the result is the integer7300.AS "Net Revenue"labels the output column with the exact header the board deck needs. The double quotes do two things at once: they let the alias contain a space (an unquoted identifier has to be a single contiguous token), and they tell PostgreSQL to take the case literally instead of folding it.
Why this and not AS Net Revenue or AS net_revenue
AS Net Revenue is a syntax error. PostgreSQL reads Net as the alias and then sees Revenue as an unexpected token sitting in the wrong place in the SELECT list. The space breaks the identifier.
AS net_revenue is a legal alias and a normal habit elsewhere. It's the right shape when you control the downstream consumer; it's the wrong shape here because the board deck requires the header Net Revenue with the space and the capitals intact. Quoting the alias at the source is one pair of characters; renaming the column after the fact is extra work.
The trap
Double quotes feel similar to single quotes, and the muscle memory from string literals is to reach for single quotes. They mean different things in SQL. Single quotes are for string values — 'Net Revenue' would be a literal string sitting in the SELECT list as a data value, not an alias. Double quotes are for identifiers. Use the wrong one and the query either errors or runs but produces a column with the wrong header. Whenever an alias needs to keep its case or contain a space, the quotes must be double quotes.
You practiced wrapping an alias in double quotes to preserve spaces and case. Unquoted identifiers fold to lowercase and forbid spaces — double quotes are the recurring fix any time the downstream consumer requires an exact column header.