I am in the beginning stages of learning SQL through Google's Data Analytics course on Coursera. While I understand the syntax of temporarily renaming tables and columns with AS ([original name] AS [new name]), I'm not quite sure I understand the order placement. There is an example they provided in Big Query shown below.
1 SELECT
2 seasons.market AS university,
3 seasons.name AS team_name,
4 seasons.wins,
5 seasons.losses,
6 seasons.ties,
7 mascots.mascot AS team_mascot
8 FROM
9 `bigquery-public-data.ncaa_basketball.mbb_historical_teams_seasons` AS seasons
10 INNER JOIN
11 `bigquery-public-data.ncaa_basketball.mascots` AS mascots
12 ON
13 seasons.team_id = mascots.id
14 WHERE
15 seasons.season = 1984
16 AND seasons.division = 1
17 ORDER BY
18 seasons.market
Essentially, what is tripping me up is how line 2 can get the right "table.column" address for "seasons.market" when bigquery-public-data.ncaa_basketball.mbb_historical_teams_seasons
is redefined as "seasons" in line 9.
With all of that said, my question is: is there an SQL function that exists simply to establish as alias? I understand that the above example works, but it is hard for me to wrap my head around a program reading lines 1,9,2,3... I would love to be able to start off my queries by plugging in relevant and concise names at the TOP, not the middle. Ideal situation shown below.
[ALIAS ESTABLISHMENT FUNCTION]
reallylongtablename1 AS tbl1
SELECT
exampleColumnA
FROM
tbl1
Thank you very much!