Given a table Employees with columns id, name, department, and salary, what will be the output of this query?
SELECT name, salary FROM Employees;
CREATE TABLE Employees (id INT, name VARCHAR(50), department VARCHAR(50), salary INT); INSERT INTO Employees VALUES (1, 'Alice', 'HR', 50000), (2, 'Bob', 'IT', 60000), (3, 'Charlie', 'Finance', 55000);
Look at the columns listed after SELECT. Only those columns will appear in the output.
The query selects only the name and salary columns from the Employees table. So the output contains only those two columns for all rows.
What will be the output of this query on the Employees table?
SELECT id, name FROM Employees WHERE salary > 55000;
CREATE TABLE Employees (id INT, name VARCHAR(50), department VARCHAR(50), salary INT); INSERT INTO Employees VALUES (1, 'Alice', 'HR', 50000), (2, 'Bob', 'IT', 60000), (3, 'Charlie', 'Finance', 55000);
Only rows where salary is greater than 55000 are included.
The query filters rows with salary > 55000. Only Bob has salary 60000, so only his id and name are returned.
Which option contains a syntax error when selecting specific columns from the Employees table?
Check if commas separate the column names correctly.
Option A misses a comma between id and name, causing a syntax error.
You want to retrieve only the name and department columns from a large Employees table. Which query is best for performance?
Select only the columns you need to reduce data transfer.
Option D selects only the needed columns, reducing data size and improving performance.
Consider this query:
SELECT name AS employee_name, salary AS employee_salary FROM Employees;
What will be the column names in the output?
Look at the AS keyword which renames columns in the output.
The AS keyword renames the columns in the result set to employee_name and employee_salary.