What is the proper syntax for assigning a column alias?
-
SELECT column_name ALIAS alias_name FROM table_name;
-
SELECT column_name alias_name FROM table_name;
-
SELECT alias_name FROM table_name;
-
ASSIGN alias_name TO column_name;
In SQL, a column alias is assigned simply by placing the alias name after the column name, optionally with the AS keyword. The syntax 'SELECT column_name alias_name' is correct. Option A shows incorrect ALIAS keyword, and Option C just selects the alias as a column name.
A column alias is assigned in SQL simply by placing the alias name after the column name (optionally with the keyword AS in between) in the SELECT list: SELECT column_name alias_name FROM table_name;. There's no ALIAS keyword in standard SQL, so option 1 is invalid syntax; SELECT alias_name FROM table_name would just try to select a column literally named alias_name (not create an alias); and ASSIGN ... TO ... isn't valid SQL syntax at all.