Q1
True / FalseSQL Aliases can only be used with SELECT statements.
SQL Aliases can be used with other statements like UPDATE and DELETE in addition to SELECT.
Q2
True / FalseAliases defined in a SELECT statement are only visible within that statement.
Aliases in a SELECT statement are not visible outside the scope of that statement.
Q3
True / FalseYou can use an alias for a table but not for a column.
Aliases can be used for both tables and columns.
Q4
True / FalseColumn aliases must be used in the WHERE clause.
Column aliases cannot be used in the WHERE clause; they can only be used in the SELECT and ORDER BY clauses.
Q5
True / FalseTable aliases can be used to simplify queries with multiple joins.
Table aliases are commonly used to simplify queries, especially those with multiple joins.
Q6
True / FalseThe alias 't' for a table cannot be used more than once in a query.
Aliases must be unique within the same query; you cannot use the same alias for different tables.
Q7
True / FalseAliases for columns can be used in the GROUP BY clause.
Column aliases can be used in the ORDER BY clause but not in the GROUP BY clause. You must use the original column names in GROUP BY.
Q8
True / FalseAn alias for a column can be a reserved SQL keyword.
Using reserved SQL keywords as aliases can lead to syntax errors or unexpected results. It's better to avoid using them as aliases.
Q9
True / FalseYou can use aliases for columns and tables in the same SQL statement.
Aliases can be used for both columns and tables within the same SQL statement, enhancing query readability.
Q10
True / FalseAliasing a column requires the AS keyword.
The AS keyword is optional when aliasing a column. You can use the alias directly after the column name.
Q11
True / FalseTable aliases are mandatory in SQL queries.
Table aliases are not mandatory. They are used to simplify queries, especially with joins, but not required for basic queries.
Q12
True / FalseYou can reference column aliases in a subquery.
Column aliases defined in the outer query cannot be referenced in the subquery.
Q13
True / FalseAliases defined in a CTE (Common Table Expression) are visible outside the CTE.
Aliases in a CTE are only visible within the CTE and the main query that references it.
Q14
True / FalseColumn aliases can be used in the HAVING clause.
Column aliases can be used in the HAVING clause, provided they are defined in the SELECT clause.
Q15
True / FalseAliasing is not allowed in SQL Server for expressions in the SELECT clause.
Aliasing is allowed for expressions in the SELECT clause to simplify reference to those expressions.
Q30
Multiple ChoiceWhich SQL snippet applies an alias to a calculated column?
SQL Code
SELECT FirstName, LastName, (Salary * 0.1) AS Bonus
FROM Employees;
The snippet uses 'Bonus' as an alias for the calculated column (Salary * 0.1).
Q41
Multiple ChoiceWhich SQL snippet correctly uses an alias for a subquery in the FROM clause?
SQL Code
SELECT AvgSales.CustomerID, AvgSales.AvgAmount
FROM (
SELECT CustomerID, AVG(SalesAmount) AS AvgAmount
FROM Sales
GROUP BY CustomerID
) AS AvgSales;
The snippet uses 'AvgSales' as an alias for the subquery in the FROM clause, which calculates the average sales amount per customer.
Q43
Multiple ChoiceWhich SQL snippet demonstrates using aliases with multiple columns?
SQL Code
SELECT EmployeeID AS ID, FirstName AS Name, Salary AS AnnualSalary
FROM Employees;
The snippet applies aliases 'ID', 'Name', and 'AnnualSalary' to the 'EmployeeID', 'FirstName', and 'Salary' columns, respectively.