Two small but constant tools: DISTINCT removes duplicate rows from a result, and aliases rename columns and tables to keep queries readable.
DISTINCT
SELECT DISTINCT programme FROM students; -- each programme onceSELECT DISTINCT programme, year FROM students; -- unique combinations
Column & table aliases
SELECT package * 100000 AS package_inr -- name a computed columnFROM students AS s -- table alias (often omit AS)WHERE s.package > 7;
Key takeaways
- 01DISTINCT removes duplicate rows (or unique combinations across several columns).
- 02A column alias (AS name) names the output column — great for computed columns.
- 03A table alias shortens references, especially in joins.
- 04Aliases make queries readable and unambiguous.
