Chapter 13: More on SQL (Solution)

Type A: Short Answer Questions / Conceptual Questions

1. What is the use of ORDER BY clause?

2. What is the default sort order of ORDER By Clause?
Ans: The ORDER BY clause sorts in Ascending order by default.

3. Which function do you use in ORDER BY clauses to specify custom sort order?
Ans:

We can use FIELD function in ORDER By clauses to specify custom sort order.
SELECT <fieldname(s)>
FROM <tablename>
ORDER BY FIELD (<columnname>, <value spcifying order>);

4. Which clause is used to sort the record of table?
Ans:

ORDER BY

5. Write an example query those sorts on three columns.
Ans:
SELECT Empname, Deptname, Designation, Salary
FROM Employee
ORDER BY Empname, Deptname DESC, Salary;

6. Write a query that sorts the data of table student on the basis of Project-Group (in ascending order), section (in descending order), Marks (in descending order)
Ans:
SELECT * FROM Student ORDER BY Project_Group, Section DESC, Mark DESC;

7. What is the difference between HAVING and GROUP BY clause?

8. What is the use of GROUP BY clause?

9. What are aggregate functions? What is their use? Give some examples.

10. What type of function can you use with GROUP BY and HAVING clauses?
Ans: We can use Aggregate functions also known as multiple row function with GROUP BY and HAVING clause.

error: Content is protected !!