MSSQL-Part 8: How to use GROUP BY, HAVING, ORDER BY clause in SQL?

#sql #learnsql #mssql
▬▬▬▬▬▬ In this Video ▶️ ▬▬▬▬▬▬
 The ORDER BY keyword is used to sort the result-set in ascending or descending order.
 The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.

GROUP BY Statement:
 The GROUP BY statement groups rows that have the same values into summary rows, like “find the number of customers in each country”.
 The GROUP BY statement is often used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or more columns.

HAVING Clause:
 The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions directly.
 Group By only goes with Having condition not with WHERE

Syntax: SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);

▬▬▬▬▬▬ Useful Links 🛠 ▬▬▬▬▬▬
Blog ►​​​
GitHub Repo ►​​

▬▬▬▬▬▬ Connect with us 👋 ▬▬▬▬▬▬
~~~Subscribe to this channel, and press bell icon to get all updated videos on Selenium and Cypress Automation:

~~~ Follow us on Facebook & Twitter to get more updates:

Comments are closed.