Memra

Choosing columns (projection)

Ask for specific columns and rename them.

Pick your columns

* is handy for a peek, but real queries name the columns they want — this is called projection. List them comma-separated in the order you want them:

SELECT title, price FROM books;

You can rename a column in the output with AS (an *alias*). This doesn't change the table — only the result's heading:

SELECT title AS book, price AS cost FROM books;

You can also compute new columns from existing ones. price * stock gives the value of the stock on hand.

NORMAL ~/memra/learn/postgresql/projection-choosing-columns utf-8 LF