Mysql Notes
Mysql Notes
Degree = 5, Cardinality = 4.
10. What is the default sorting order when using ORDER BY?
The default sorting order is ascending.
11. What is the purpose of the GROUP BY clause in SQL?
The GROUP BY clause is used to group rows that have the same values in specified
columns and apply aggregate functions like SUM(), COUNT(), AVG(), etc., on the
grouped data.
12. What is the primary difference between COUNT(*) and COUNT(column) in SQL?
COUNT(*) counts all rows, including NULL values, while COUNT(column) ignores
NULL values.
13. Difference between ORDER BY and GROUP BY in SQL:
o ORDER BY is used to sort the result set in ascending (ASC) or descending
(DESC) order.GROUP BY is used to group rows that have the same values in
specified columns, often for aggregate calculations.
o ORDER BY is typically used to arrange the output for better readability.
GROUP BY is commonly used with aggregate functions like SUM(), COUNT(),
AVG(), MAX(), or MIN().
14. Can GROUP BY be used without aggregate functions? Justify your answer.
No, GROUP BY is generally used with aggregate functions. Without aggregate
functions, it is ineffective since its purpose is to summarize data.
15. What is the difference between WHERE and HAVING clauses?
WHERE is used to filter rows before grouping, while HAVING is used to filter grouped
data after applying aggregate functions.
16. What is an equi-join in SQL?
An equi-join is a type of join that combines rows from two or more tables based on
matching column values, typically using the = operator.
17. Write an SQL query using an equi-join to display employee names and their
department names from Employee and Department tables.
Single-row functions operate on each row individually and return one result
per row (e.g., UPPER(), LENGTH()).