0% found this document useful (0 votes)
5 views

SQL CH 03

This document contains 34 multiple choice questions about SQL SELECT statements. It covers the required and optional clauses of SELECT like SELECT, FROM, WHERE, ORDER BY, GROUP BY and topics like filtering rows, sorting results, aliases, string operations, arithmetic operations, logical operators and pattern matching with wildcards.

Uploaded by

tarifditcr60
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

SQL CH 03

This document contains 34 multiple choice questions about SQL SELECT statements. It covers the required and optional clauses of SELECT like SELECT, FROM, WHERE, ORDER BY, GROUP BY and topics like filtering rows, sorting results, aliases, string operations, arithmetic operations, logical operators and pattern matching with wildcards.

Uploaded by

tarifditcr60
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Q1. Which clause of a SELECT statement is required?

A. SELECT
B. FROM
C. WHERE
D. ORDER BY
Answer: A
[Ref. Page 86]
Q2. Which clause of a SELECT statement is used to filter rows?
A. SELECT
B. FROM
C. WHERE
E. ORDER BY
Answer: C
[Ref. Page 86]
Q3. Which clause of a SELECT statement is used to specify how the result of the query be sorted?
A. SELECT
B. FROM
C. WHERE
D. ORDER BY
Answer: D
Q4. Which one correctly defines the predicates in SELECT query?
A. The column names of base table(s) that are to be included in the result
B. The table names from which query will retrieve data
C. Boolean expressions that are placed with WHERE clause and the expression must evaluate to
true for a row to be included in the result set
D. The column names which will affect the sort order of the query result
Answer: C
[Ref. Page 87, Description points]
Q5. Boolean expressions or predicates that are used which WHERE clause must result in a value of
_______________?
A. True or False
B. True, False or Unknown (NULL)
C. 0 or 1
D. 0,1or Unknown (NULL)
Answer: B
[Ref. Page 87, Description points]
Q6. How the result will be returned, if you do not include ORDER BY clause in a SELECT query?
A. The result will be returned in the same order as they appear in the base table
B. The result will be returned in primary key sequence
C. The result will be returned in random order
D. No results will be returned; you must include the ORDER BY clause
Answer: A
[The result will be returned in the same order as they appear in the base table, in most cases they are
in primary key sequence
Ref. Page 87, Description points]
Q7. Which one is used to indicate all columns of the source table should be included in the result of a
SELECT query?
A. ?
B. %
C. _
D. *
Answer: D
Q8. Why do you use column alias in a SELECT statement?
A. To name an expression
B. To change column heads
C. To rename column of base table
D. All of the above
Answer: B
Q9. Which one is NOT a valid alias for ContactFName column?
A. ContactFName AS ‘First Name’
B. ContactFName ‘First Name’
C. ‘First Name’ = ContactFName
D. ContactFName = ‘First Name’
Answer: D
[Column Aliasing Rules:
1. Column AS alias
2. Column alias (AS is optional)
3. Alias = column
Rule 3 works only in SQL Server]
[Ref. Page: 91-92]
Q10. Any name that does not follow the SQL Server’s rules for naming object must be enclosed in
________________.
A. Brackets []
B. Curly braces {}
C. In parentheses ()
D. In single quotes
Answer: A
[Ref. Page: 92]
Q11. Which one is the string concatenation operation in SQL Server?
A. &
B. .
C. +
D. -
Answer: C
Q12. Which one is valid string literal?
A. “SQL Server”
B. ‘SQL Server’
C. [SQL Server]
D. SQL Server
Answer: B
Q13. How can you include a single quote or apostrophe in a string literal?
A. By placing two single quotes
B. By placing a backslash before the quote character
C. By placing a @ character before the string literal
D. By enclosing the quote character within double quotes
Answer: A
[Just replace single quote (‘) with double single quotes (‘’)
‘Granma’s recipe’ - is invalid
‘Granma’’s recipe’ is valid]
[Ref. Page: 95]
Q14. Which one is the correct order of precedence of arithmetic operators in SQL Server?
A. Multiplication, division and modulo operations are done first, followed by addition and
subtraction
B. Modulo operation is done first, followed by multiplication, division, addition and subtraction
C. Multiplication, division, addition and subtraction operations are done first, followed by modulo
operations
D. Addition, subtraction and modulo operations are done first, followed by multiplication and
division
Answer: A
[Ref. Page: 97]
Q15. The operations in an expression take place __________________in the order of precedence.
A. from left to right
B. from right to left
C. as decided by query optimizer
D. as they appear
Answer: A
[Ref. Page: 97]
Q16. __________________performs an operation and returns a value.
A. A query
B. A stored procedure
C. A function
D. A view
Answer: C
Q17. Which one returns current date and time?
A. NOW()
B. DATE()
C. DATETIME()
D. GETDATE()
Answer: D
Q18. Which keyword do you use in the SELECT clause to eliminate duplicates?
A. UNIQUE
B. ALL
C. DISTINCT
D. REMOVE DUPLICATE
Answer: C
Q19. The DISTINCT keyword removes duplicates from the result set and also
__________________________________?
A. causes the result set to be grouped by the first column
B. causes the result set to be sorted by the first column
C. causes the result set to be grouped by the last column
D. causes the result set to be sorted by the last column
Answer: B
Q20. Why is TOP clause in a SELECT statement used?
A. To limit the number of rows that are retrieved by the SELECT statement
B. To filter out the rows retrieved by the SELECT statement
C. To group the rows retrieved by the SELECT statement
D. To sort the rows retrieved by the SELECT statement
Answer: A
Q21. How can specify in TOP clause to include additional rows that have the same values as the last
row?
A. Include DISTINCT keyword WITH TOP clause
B. Include ALL keyword with TOP clause
C. Include ANY keyword with TOP clause
D. Include WITH TIES with TOP clause
Answer: D
Q22. Which SELECT statement will not work?
A. SELECT TOP 3 product name, price FROM products ORDER BY price DESC
B. SELECT TOP 3% product name, price FROM products ORDER BY price DESC
C. SELECT TOP 3 PERCENT product name, price FROM products ORDER BY price DESC
D. SELECT TOP 3 WITH TIES product name, price FROM products ORDER BY price DESC
Answer: B
Q23. You use _________________to create compound conditions.
A. Arithmetic operators
B. Comparison operators
C. Logical operators
D. Functions
Answer: C
[AND, OR, NOT]
Q24. The order of evaluation of logical operators is ________
A. AND, OR, NOT
B. OR, AND, NOT
C. NOT, AND, OR
D. NOT, OR, AND
Answer: C
Q25. Which phrase do you use to test whether an expression is equal to any value in a list?
A. =
B. ==
C. IS
D. IN
Answer: D
[Example
SELECT * FROM Customers WHERE Country IN (‘USA’, ‘UK’, ‘Germany’)]
Q26. See the SELECT statement
SELECT * FROM Orders WHERE OrderDate BETWEEN '2017-01-01’ AND ‘2017-12-31’
Where one of the following is equivalent to the above query?
A. SELECT * FROM Orders WHERE OrderDate > '2017-01-01’ AND OrderDate < ‘2017-12-31’
B. SELECT * FROM Orders WHERE OrderDate > '2017-01-01’ OR OrderDate < ‘2017-12-31’
C. SELECT * FROM Orders WHERE OrderDate >= '2017-01-01’ AND OrderDate <= ‘2017-12-31’
D. SELECT * FROM Orders WHERE OrderDate >= '2017-01-01’ OR OrderDate <= ‘2017-12-31’
Answer: C
Q27. Which operator do you use to retrieve rows that match a string pattern or mask?
A. =
B. ==
C. IS
D. LIKE
Answer: D
Q28. Which wildcard character indicates any string of zero or more characters?
A. -
B. %
C. _
D. ?
Answer: B
[Ref. Page: 110]
Q29. Which wildcard character indicates any single character?
A. -
B. %
C. _
D. ?
Answer: C
[Ref. Page: 110]
Q30. LIKE ‘%ER’ will match ____________.
A. “Computer” and “James Peter”
B. “Computer” and “Peter, James”
C. “Using Computer” and “Computer World”
D. “Computer1” and “Computer2”
Answer: A
Q31. LIKE ‘N[A-J]’ will not match _____________.
A. NA
B. NC
C. NJ
D. NY
Answer: D
Q32. LIKE ‘N[^A-J]’ will match _____________.
A. NA
B. NC
C. NJ
D. NY
Answer: D
Q33. To test a null value, you use___________.
A. = or <> operators
B. == or != operators
C. IS NULL or IS NOT operators
D. ISNULL function
Answer: C
Q33. Which keywords are most useful when a client application needs to retrieve rows one page at a
time?
A. TOP and WITH TIES
B. ASC and DESC
C. GROUP BY and HAVING
D. FETCH and OFFSET
Answer: D
[Ref. Page: 121]
Q34. Which query returns the highest three marks achiever?
A. SELECT TOP 3 StudentID, Marks FROM Results
B. SELECT TOP 3 StudentID, Marks FROM Results ORDER BY Marks DESC OFFSET 0 ROWS
C. SELECT StudentID, Marks FROM Results ORDER BY Marks OFFSET 0 ROW FETCH NEXT 3 ROWS
ONLY
D. SELECT StudentID, Marks FROM Results ORDER BY Marks DESC OFFSET 0 ROWS FETCH NEXT 3
ROWS ONLY
Answer: D
[A. Does not return desired results
B. Cannot use TOP with OFFSET
C. Returns lowest marks achiever]

You might also like