Guided Notes

AS & WITH (Common Table Expressions)

Aliasing with AS and organizing complex queries with WITH ... AS.

Aliasing with AS

Slide 1 / 5

AS gives a column or table a new name in your query:

SELECT DATE(block_timestamp) AS trans_date, COUNT(*) AS num_transactions FROM transactions AS t

Column aliases make results readable and let later clauses (like ORDER BY) refer to a short, meaningful name. Table aliases shorten long table names, which becomes essential with joins.

← ORDER BY & Dates