Aliases in SQL with AS | SQL Bits | Kovolff
Channel: prelearn
Date: 2020-12-03

Aliases in SQL are created with theSQL keyword AS
With aliases you give your fields and tables different names
i.e.:
SELECT vorname AS "first_name", nachname AS "surname", nation FROM fahrer AS drivers

Sorting with aliases
i.e.:
SELECT vorname AS "first_name", nachname AS "surname", nation FROM fahrer AS drivers
ORDER BY nation, surname, first_name

Filtering requires you enclose your query within an outer query, i.e.
SELECT * FROM
(
 SELECT vorname AS "first_name", nachname AS "surname", nation
 FROM fahrer AS drivers
) AS outer_query

WHERE outer_query.surname LIKE 'B%'

ORDER BY nation, surname, first_name

Formel 1 Data: https://ergast.com/mrd/db/#csv

#sql #alias #as #databases #views