




























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























Question 1 Which clause is used to filter rows in a SQL query? A. ORDER BY B. GROUP BY C. WHERE D. HAVING Correct Answer: C. WHERE Rationale: The WHERE clause is used to filter rows before any grouping or aggregation occurs. It evaluates each row against a condition and returns only those that meet the criteria. ORDER BY is used for sorting, GROUP BY is for aggregation grouping, and HAVING filters groups after aggregation. Question 2 Which SQL keyword is used to sort query results? A. SORT BY B. ORDER BY C. GROUP BY D. ARRANGE BY
Correct Answer: B. ORDER BY Rationale: ORDER BY is used to sort results in ascending or descending order based on one or more columns. SORT BY and ARRANGE BY are not valid SQL Server keywords. GROUP BY is used for aggregations, not sorting. Question 3 Which function is used to count rows in a table? A. SUM() B. COUNT() C. TOTAL() D. NUMBER() Correct Answer: B. COUNT() Rationale: COUNT() returns the number of rows that match a condition or exist in a table. SUM() adds numeric values, while TOTAL() and NUMBER() are not valid SQL Server aggregate functions. Question 4 What does INNER JOIN return? A. All rows from both tables B. Only unmatched rows C. Only matching rows from both tables D. All rows from left table only Correct Answer: C. Only matching rows from both tables Rationale: INNER JOIN returns only records where there is a match in both joined tables based on the join condition. Non-matching rows are excluded. Question 5
Correct Answer: B. % Rationale: The % wildcard in SQL Server represents zero or more characters in a LIKE pattern. _ represents a single character. Question 8 What does GROUP BY do? A. Sorts results B. Filters rows C. Groups rows for aggregation D. Joins tables Correct Answer: C. Groups rows for aggregation Rationale: GROUP BY groups rows that share values in specified columns so aggregate functions like SUM or COUNT can be applied. Question 9 Which clause filters grouped results? A. WHERE B. HAVING C. ORDER BY D. GROUP BY Correct Answer: B. HAVING Rationale: HAVING filters aggregated results after GROUP BY is applied, while WHERE filters rows before grouping. Question 10 Which statement is used to retrieve data?
Correct Answer: A. SELECT Rationale: SELECT is used to query and retrieve data from one or more tables. Other options modify data. Question 11 Which JOIN returns all rows from the left table and matching rows from the right? A. INNER JOIN B. RIGHT JOIN C. LEFT JOIN D. FULL JOIN Correct Answer: C. LEFT JOIN Rationale: LEFT JOIN returns all rows from the left table and matched rows from the right table; unmatched right rows return NULL. Question 12 Which keyword is used to insert data? A. ADD B. INSERT C. UPDATE D. CREATE Correct Answer: B. INSERT Rationale: INSERT INTO is used to add new rows into a table. UPDATE modifies existing rows, and CREATE defines structures.
Correct Answer: B. DELETE Rationale: DELETE removes rows from a table while preserving structure. DROP removes entire objects like tables. Question 16 Which clause limits number of rows returned? A. LIMIT B. TOP C. FETCH D. FIRST Correct Answer: B. TOP Rationale: In SQL Server, TOP is used to limit the number of rows returned by a query. LIMIT is used in MySQL. Question 17 What is a primary key? A. Allows duplicates B. Uniquely identifies each row C. Foreign reference D. Optional column Correct Answer: B. Uniquely identifies each row Rationale: A primary key uniquely identifies each record and cannot contain NULL or duplicate values. Question 18 What does FOREIGN KEY do?
A. Deletes records B. Links tables C. Sorts data D. Encrypts data Correct Answer: B. Links tables Rationale: A foreign key establishes relationships between tables by referencing primary keys. Question 19 Which operator checks multiple values? A. BETWEEN B. IN C. LIKE D. EXISTS Correct Answer: B. IN Rationale: IN checks whether a value exists within a specified list of values. Question 20 Which keyword creates a table? A. MAKE TABLE B. CREATE TABLE C. NEW TABLE D. BUILD TABLE Correct Answer: B. CREATE TABLE Rationale: CREATE TABLE defines a new table structure in the database. Question 21
Question 24 Which clause is executed first logically? A. SELECT B. WHERE C. FROM D. ORDER BY Correct Answer: C. FROM Rationale: FROM identifies source tables and is logically processed before filtering or selection. Question 25 What does ALIAS do? A. Deletes column B. Renames column or table temporarily C. Encrypts data D. Sorts data Correct Answer: B. Renames column or table temporarily Rationale: Aliases provide temporary names for columns or tables for readability. Question 26 Which join returns all rows from both tables? A. INNER JOIN B. LEFT JOIN C. FULL OUTER JOIN D. CROSS JOIN
Correct Answer: C. FULL OUTER JOIN Rationale: FULL OUTER JOIN returns all rows from both tables, matching where possible and filling NULLs otherwise. Question 27 What does CROSS JOIN produce? A. Matched rows only B. Cartesian product C. Filtered rows D. Grouped rows Correct Answer: B. Cartesian product Rationale: CROSS JOIN returns every combination of rows between two tables. Question 28 Which keyword modifies existing data? A. UPDATE B. CHANGE C. MODIFY D. ALTER DATA Correct Answer: A. UPDATE Rationale: UPDATE changes existing records in a table based on conditions. Question 29 Which function removes NULL values in results? A. IS NULL B. COALESCE
Correct Answer: A. MIN() Rationale: MIN() returns the smallest value in a column. Question 33 Which statement is used to modify table structure? A. UPDATE B. ALTER TABLE C. MODIFY TABLE D. CHANGE TABLE Correct Answer: B. ALTER TABLE Rationale: ALTER TABLE is used to add, remove, or modify columns. Question 34 Which operator tests existence of rows? A. EXISTS B. IN C. LIKE D. ANY Correct Answer: A. EXISTS Rationale: EXISTS checks whether a subquery returns any rows. Question 35 Which clause must always come after SELECT?
Correct Answer: B. FROM Rationale: FROM defines the data source and is required for querying tables. Question 36 Which function concatenates strings? A. JOIN() B. CONCAT() C. APPEND() D. MERGE() Correct Answer: B. CONCAT() Rationale: CONCAT() combines multiple string values into one result. Question 37 Which keyword enforces uniqueness? A. UNIQUE B. DISTINCT C. PRIMARY KEY D. CHECK Correct Answer: C. PRIMARY KEY Rationale: Primary key enforces uniqueness and not-null constraints. Question 38 Which clause is used with aggregate filtering?
Correct Answer: A. DISTINCT Rationale: DISTINCT ensures unique result sets when used in SELECT statements. Question 42 Which SQL clause specifies columns to return? A. FROM B. SELECT C. WHERE D. ORDER BY Correct Answer: B. SELECT Rationale: SELECT defines which columns are returned in query output. Question 43 Which function returns current date? A. TODAY() B. GETDATE() C. NOWDATE() D. CURRENT() Correct Answer: B. GETDATE() Rationale: GETDATE() returns current system date and time in SQL Server. Question 44 Which keyword is used for conditional logic?
Correct Answer: A. CASE Rationale: CASE provides conditional logic within SQL queries. Question 45 Which operator compares values? A. = B. LIKE C. BETWEEN D. IN Correct Answer: A. = Rationale: = is used for equality comparison. Question 46 Which clause defines join condition? A. ON B. WHERE C. USING D. LINK Correct Answer: A. ON Rationale: ON specifies the join condition between tables. Question 47 Which function returns string length?
Correct Answer: B. SUM() Rationale: SUM() calculates total of numeric column values. Question 51 Which keyword removes all rows quickly? A. DELETE B. TRUNCATE C. DROP D. CLEAR Correct Answer: B. TRUNCATE Rationale: TRUNCATE removes all rows efficiently without logging individual row deletions. Question 52 Which operator is used in subqueries? A. EXISTS B. ALL C. ANY D. IN Correct Answer: D. IN Rationale: IN is commonly used to compare values against subquery results. Question 53
Which clause controls output sorting? A. GROUP BY B. ORDER BY C. HAVING D. FILTER Correct Answer: B. ORDER BY Rationale: ORDER BY determines sorting order of query results. Question 54 Which function replaces NULL values? A. NVL B. ISNULL C. COALESCE D. All of the above Correct Answer: D. All of the above Rationale: SQL Server supports ISNULL and COALESCE for NULL handling. Question 55 Which keyword creates database object? A. CREATE B. BUILD C. NEW D. GENERATE Correct Answer: A. CREATE Rationale: CREATE defines new database objects like tables and views. Question 56