Master T-SQL Fundamentals for SQL Server with these MCQs on SELECT queries, filtering with WHERE, sorting with ORDER BY, and an introduction to Transact-SQL. Sharpen your skills with practical scenarios.
SELECT * FROM Employees?
SELECT 'SQL Server' AS Technology;
SELECT * FROM Employees WHERE Salary > 5000;SELECT * FROM Employees HAVING Salary > 5000;SELECT * FROM Employees GROUP BY Salary > 5000;SELECT * FROM Employees ORDER BY Salary > 5000;WHERE Age BETWEEN 18 AND 30WHERE Age IS BETWEEN 18 AND 30WHERE Age IN BETWEEN 18 AND 30WHERE Age RANGE 18 TO 30SELECT * FROM Products WHERE Price <> 100;
SELECT * FROM Employees ORDER BY Department, Salary DESC;
SELECT TOP 5 Salary FROM Employees ORDER BY Salary DESC;SELECT * FROM Employees ORDER BY Salary ASC LIMIT 5;SELECT Salary FROM Employees GROUP BY Salary DESC;SELECT DISTINCT TOP 5 Salary FROM Employees;SELECT * FROM Orders ORDER BY DateCreated ASC;
| Qno | Answer |
|---|---|
| 1 | B) Performing data manipulation and querying |
| 2 | B) It is an extension of standard SQL for Microsoft SQL Server. |
| 3 | A) Enhanced support for procedural programming |
| 4 | A) PRINT ‘Hello World!’ |
| 5 | A) Marks the end of a batch of T-SQL statements |
| 6 | A) MONEY |
| 7 | B) Retrieves data from a table |
| 8 | A) FROM |
| 9 | B) All columns and rows from the Employees table are retrieved. |
| 10 | A) Use the AS keyword |
| 11 | B) Displays the value “SQL Server” under a column named “Technology” |
| 12 | A) DISTINCT |
| 13 | A) Filters rows based on a condition |
| 14 | A) SELECT * FROM Employees WHERE Salary > 5000; |
| 15 | A) IS NULL |
| 16 | A) WHERE Age BETWEEN 18 AND 30 |
| 17 | B) All rows with Price not equal to 100 |
| 18 | D) All of the above |
| 19 | B) Sorts rows based on a specified column |
| 20 | A) DESC |
| 21 | A) Ascending |
| 22 | A) Use a comma to separate column names in the ORDER BY clause |
| 23 | B) The query sorts first by Department and then by Salary in descending order. |
| 24 | A) SELECT TOP 5 Salary FROM Employees ORDER BY Salary DESC; |
| 25 | D) All of the above |
| 26 | B) Orders are displayed with the oldest date first. |
| 27 | C) Yes, but only with an alias |
| 28 | A) NULL values appear first. |
| 29 | A) TOP |
| 30 | A) By specifying each column’s order individually in the ORDER BY clause |