MySQL MCQ set number 00363

1. Keyword “ASC” and “DESC” cannot be used without which clause in Mysql?
a) ORDER BY
b) GROUP BY
c) SELECT
d) HAVING

Answer

Answer: a [Reason:] “ASC” or “DESC” are used to sort the result set in ascending or descending order therefore they cannot be used without “ORDER BY” clause.

2. What is the significance of “ORDER BY emp_id DESC” in the given query?

SELECT emp_id, fname, lname
FROM person
ORDER BY emp_id DESC;

a) Data of emp_id will be sorted in descending order
b) Data of emp_id will be sorted in ascending order
c) Data of emp_id will be sorted in either ascending or descending order
d) All of the mentioned

Answer

Answer: a [Reason:] Keyword “DESC” will sort the data in descending order.

3. What is the significance of “ORDER BY emp_id ASC” in the given query?

SELECT emp_id, fname, lname
FROM person
ORDER BY emp_id ASC;

a) Data of emp_id will be sorted in descending order
b) Data of emp_id will be sorted in ascending order
c) Data of emp_id will be sorted in either ascending or descending order
d) All of the mentioned

Answer

Answer: b [Reason:] Keyword “ASC” will sort the data in ascending order.

4. If emp_id contain the following set {9, 7, 6, 4, 3, 1, 2}, what will be the output on execution of the given query?

SELECT emp_id
FROM person
ORDER BY emp_id DESC;

a) {9, 7, 6, 4, 3, 1, 2}
b) {1, 2, 3, 4, 6, 7 , 9}
c) {2, 1, 3, 4, 6, 7, 9}
d) None of the mentioned

Answer

Answer: a [Reason:] “DESC” clause sort the emp_id in the descending order.

5. If emp_id contain the following set {9, 7, 6, 4, 3, 1, 2}, what will be the output on execution of the given query?

SELECT emp_id
FROM person
ORDER BY emp_id ASC;

a) {9, 7, 6, 4, 3, 1, 2}
b) {1, 2, 3, 4, 6, 7, 9}
c) {2, 1, 3, 4, 6, 7, 9}
d) None of the mentioned

Answer

Answer: b [Reason:] “ASC” clause sort the emp_id in the ascending order.

6. Find odd one out?
a) GROUP BY
b) DESC
c) ASC
d) ORDER BY

Answer

Answer: a [Reason:] “ORDER BY”, “DESC”, “ASC” are related to sorting whereas “GROUP BY” is not related to sorting.

7. Is there any error in the following query?

SELECT emp_id, title, start_date, fname, fed_id
FROM person
ORDER BY RIGHT (fed_id, 3);

a) Yes
b) No error
c) Depends
d) None of the mentioned

Answer

Answer: b [Reason:] “ORDER BY” clause can be used with expression such as fed_id, which is a social security no like 111, 111, 111 therefore we sort it taking only three digits from right.

8. Is there any error in the following query?

SELECT emp_id, title, start_date, fname, fed_id
FROM person
ORDER BY LEFT (fed_id, 3);

a) Yes
b) No error
c) Depends
d) None of the mentioned

Answer

Answer: b [Reason:] “ORDER BY” clause can be used with expression such as fed_id which is a social security no like 111, 111, 111 therefore we sort it taking only three digits from left.

9. Is there any error in the following query?

SELECT emp_id, title, start_date, fname, fed_id
FROM person
ORDER BY 2, 5;

a) Yes
b) No
c) Depends
d) None of the mentioned

Answer

Answer: b [Reason:] “ORDER BY” clause can be used with Place holders. Here “2” represent column “title” and “5” represent “fed_id”. Therefore it look like “ORDER BY title, fed_id”.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.