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.
Code
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
Basic & Bearer Auth Header ToolEncode and decode HTTP Authorization Basic and Bearer headers locally with UTF-8 Base64 validation and automatic JWT claim and expiry inspection.CSV Column AnalyzerProfile every CSV column with inferred types, empty-cell counts, unique values, and numeric min and max ranges.GraphQL Query FormatterPretty-print a GraphQL query by indenting selection sets by brace depth and normalizing punctuation spacing.JSONPath TesterTest JSONPath expressions against JSON documents with dot notation, brackets, wildcards, and recursive descent.
FAQ
- Which relations are involved here?
- `products`.
Report a problem with this exampleOpens a pre-filled issue on GitHub.