16.
When a query doesn’t have an ORDER BY clause, what is the order in which the rows
are returned?
- A.Arbitrary order
- B.Primary key order
- C.Clustered index order
- D.Insertion order
- Answer & Explanation
- Report
Answer : [A]
Explanation :
Explanation :
A. Correct: Without an ORDER BY clause, ordering isn’t guaranteed and is said to be
arbitrary—it’s optimization-dependent. B. Incorrect: Without an ORDER BY clause, there’s no guarantee for ordering. C. Incorrect: Without an ORDER BY clause, there’s no guarantee for ordering. D. Incorrect: Without an ORDER BY clause, there’s no guarantee for ordering. |
17.
You want result rows to be sorted by orderdate descending, and then by orderid,
descending. Which of the following clauses gives you what you want?
- A.ORDER BY orderdate, orderid DESC
- B.ORDER BY DESC orderdate, DESC orderid
- C.ORDER BY orderdate DESC, orderid DESC
- D.DESC ORDER BY orderdate, orderid
- Answer & Explanation
- Report
Answer : [C]
Explanation :
Explanation :
A. Incorrect: This uses ascending ordering for orderdate and descending just for
orderid. B. Incorrect: This is invalid syntax. C. Correct: The correct syntax is to specify DESC after each expression whose ordering direction needs to be descending. D. Incorrect: This is invalid syntax. |
18.
You want result rows to be sorted by orderdate ascending, and then by orderid,
ascending. Which of the following clauses gives you what you want? (Choose all
that apply.)
- A.ORDER BY ASC(orderdate, orderid)
- B.ORDER BY orderdate, orderid ASC
- C.ORDER BY orderdate ASC, orderid ASC
- D.ORDER BY orderdate, orderid
- Answer & Explanation
- Report
Answer : [B, C, D]
Explanation :
Explanation :
A. Incorrect: This is invalid syntax. B. Correct: The default direction is ascending, so this clause uses ascending order for both orderdate and orderid. C. Correct: This clause explicitly uses ascending order for both orderdate and orderid. D. Correct: The default direction is ascending, so this clause uses ascending order for both orderdate and orderid. |
19.
You execute a query with a TOP (3) option. Which of the following options most accurately
describes how many rows will be returned?
- A.Fewer than three rows
- B.Three rows or fewer
- C.Three rows
- D.Three rows or more
- E.More than three rows
- F.Fewer than three, three, or more than three rows
- Answer & Explanation
- Report
Answer : [B]
Explanation :
Explanation :
A. Incorrect: If there are at least three rows in the query result without TOP, the
query will return three rows. B. Correct: If there are fewer rows than three in the query result without TOP, the query will return only those rows. If there are three rows or more without TOP, the query will return three rows. C. Incorrect: If there are fewer rows than three in the query result without TOP, the query will return only those rows. D. Incorrect: Unless the WITH TIES option is used, the query won’t return more than the requested number of rows. E. Incorrect: Unless the WITH TIES option is used, the query won’t return more than the requested number of rows. F. Incorrect: Unless the WITH TIES option is used, the query won’t return more than the requested number of rows. |
20.
You execute a query with TOP (3) WITH TIES and nonunique ordering. Which of the
following options most accurately describes how many rows will be returned?
- A.Fewer than three rows
- B.Three rows or fewer
- C.Three rows
- D.Three rows or more
- E.More than three rows
- F.Fewer than three, three, or more than three rows
- Answer & Explanation
- Report
Answer : [F]
Explanation :
Explanation :
A. Incorrect: If there are at least three rows in the query result without TOP, the
query will return at least three rows. B. Incorrect: If there are more than three rows in the result, as well as ties with the third row, the query will return more than three rows. C. Incorrect: If there are fewer rows than three in the query result without TOP, the query will return only those rows. If there are more than three rows in the result, as well as ties with the third row, the query will return more than three rows. D. Incorrect: If there are fewer rows than three in the query result without TOP, the query will return only those rows. E. Incorrect: If there are three rows or less in the query result without TOP, the query won’t return more than three rows. F. Correct: If there are fewer rows than three in the query result without TOP, the query will return only those rows. If there are at least three rows in the result and no ties with the third, the query will return three rows. If there are more than three rows in the result, as well as ties with the third row, the query will return more than three rows. |