RSS Feed

Multiple Choice Questions - SQL ORDER BY

Multiple Choice Questions - SQL ORDER BY

1. ORDER BY can limit the number of rows returned in the result set of a query.

A) True
B) False

2. Columns of type .......... cannot be used in an ORDER BY clause.

A) image
B) xml
C) ntext
D) varchar

3. ORDER BY, when used with a SELECT…INTO statement, to insert rows from another source, guarantees that the rows are inserted in the specified order.

A) True
B) False

4. Below is table 'Persons'.

LastName FirstName
aaa_L aaa_F
bbb_L bbb_F
ccc_L ccc_F
ddd_L ddd_F
eee_L eee_F
null exe_F

Following query is run on the above table:
Select LastName from persons
ORDER BY (case when lastname is null
          then
          1
          else
          0
          end), LastName

A) Result will show the values in ascending order with Null at the beginning.
B) Result will show the values in ascending order with Null at the end.
C) Result will show the values in descending order with Null at the beginning.
D) Result will show the values in descending order with Null at the end.

5. If a table name is aliased in the FROM clause then only the alias name can be used to qualify its columns in the ORDER BY clause.

A) True
B) False

6. Below is table 'Persons'.

LastName FirstName
aaa_L aaa_F
bbb_L bbb_F
ccc_L ccc_F
ddd_L ddd_F
eee_L eee_F
exe_L exe_F

When following query is run on the above table then:
Select * from Persons
where FirstName like '%F'
Order by LastName

A) result set will not be sorted in ascending order on LastName.
B) result set will be sorted in descending order on LastName.
C) result set will be sorted in ascending order on FirstName
D) result set will be same as shown above.

7. ORDER BY items must appear in the SELECT list if the statement contains ......... operator.

A) Except
B) Union
C) Intersect
D) Both A & B

8. ........ columns can be included in the ORDER BY clause.

A) 256
B) 1024
C) 32768
D) unlimited

9. With ORDER BY clause ........... is the default sort order.

A) descending
B) ascending
C) no order
D) none of above

10. Columns often specified in the ORDER BY clause are potential candidates for clustered indexes.

A) True
B) False

Answers