# [Type A] Chapter – 14 Class 12 CS – Sumita Arora Assignment | Q/A

Here is class 12 computer science [TYPE A] Unit 14 solutions for Sumita Arora back exercise assignment. Below includes both textual and video solutions wherever required. View all the answers in assignment for chapter 14 and for all chapters here.

Watch all tutorials for chapter 12.

Q1. What is the use of ORDER BY clause?

The SQL ORDER BY clause is used to sort the data in ascending or descending order, based on one or more columns. SQL sort the query results in ascending order by default.

Q2. What is the default sort order of ORDER BY clause?

SQL sort the query results in ascending order by default.

Q3. Which function do you use in ORDER BY clauses to specify sort order?

ASC is for the ascending order sorting and DESC is for the descending order sorting.
Such as in below shown code.

```SELECT * FROM STUDENT1
ORDER BY AvgMark DESC;```

Q4. Write an example query that sorts on three columns.
```SELECT prod_id, prod_price, prod_name, pros_discount FROM Products
ORDER BY prod_price, prod_name, prod_discount DESC;```
Q5. Write an example 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).
```SELECT Project-Group, section, Marks FROM Student
ORDER BY Project-Group ASC, section DESC, Marks DESC;```
Q6. What is difference between HAVING and WHERE clause?

The main difference between WHERE and HAVING clause comes when used together with GROUP BY clause, in this case WHERE is used to filter rows before grouping and HAVING is used to exclude records after grouping.

Q7. What is use of GROUP BY clause?

GROUP BY clause can be used in a SELECT statement to collect data across multiple records and group the results by one or more columns with ease.

Q8. What are aggregate function? What is their use? Give some example.

An aggregate function performs a calculation one or more values and returns a single value.
The aggregate function is often used with the GROUP BY clause and HAVING clause of the SELECT statement.

Some examples are SUM(), COUNT(), MIN(), MAX(), VAR(), STDEV().

Q9. What type of functions can you use with GROUP BY and HAVING clauses?

The SELECT statement used in the GROUP BY clause can only be used contain column names, aggregate functions, constants and expressions.
The HAVING clause is used to restrict the results returned by the GROUP BY clause.

Clear Doubts with Computer Tutor
In case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in