Basic SELECT with Column Aliases

Demonstrates a basic SELECT query with column aliases, literal expressions, and calculated columns for retrieving and shaping data from a table.

SqlData Fetching

Code

snippet
SELECT
    product_id AS id,
    product_name AS "Product Name",
    unit_price AS price,
    unit_price * 1.1 AS price_with_tax,
    'USD' AS currency,
    CURRENT_DATE AS query_date
FROM products
WHERE category_id = 1
  AND unit_price > 10.00
ORDER BY unit_price DESC
LIMIT 10;

What the code does

The statement is SELECT, touching products.

Clause by clause, expect: a WHERE clause constraining which rows the statement operates on; an ORDER BY that fixes the output order; a row cap (LIMIT) bounding the result size.

Applying it

Run the statement against the products table; the LIMIT keeps the probe cheap while you tune the predicates.

Statements that matter

SELECT
    product_id AS id,
    product_name AS "Product Name",
    unit_price AS price,
    unit_price * 1.1 AS price_with_tax,
    'USD' AS currency,
    CURRENT_DATE AS query_date
FROM products
WHERE category_id = 1
  AND unit_price > 10.00
ORDER BY unit_price DESC
LIMIT 10;

Interactive Tools for This Topic

FAQ

Which relations are involved here?
`products`.