GROUP BY and HAVING in SQL || Lesson 82 || DBMS || Learning Monkey ||

Published: 29 December 2021
on channel: Learning Monkey
893
24

GROUP BY and HAVING in SQL

We will try to understand GROUP BY and HAVING in SQL in this class.

We have already discussed Nested queries in our previous class.

GROUP BY and HAVING in SQL
GROUP BY in SQL

The GROUP BY clause in a SQL command is to group rows with the same values.

The use of the GROUP BY clause is in the SELECT statement.

It is used with aggregate functions to produce summary reports from the database.
HAVING in SQL

Having is used to restrict the rows affected by the GROUP BY clause. It is similar to the WHERE clause.
Example Queries on GROUP BY & Having in SQL

Query 1: Find the count of projects for each location.

To execute this query, we need the project table of the company database, as shown below.

We have to count the number of projects in each location from the above table.

For that to happen, we have to GROUP BY the plocation column of the project table.

The query and the output for the question are below.

Query 2: Find the project locations which have two projects.

The above question states a condition on query 1.

To restrict the number of rows of the output using GROUP BY, we must use HAVING.

#learningmonkey #dbms #placements #gatecse #gatedbms #campusplacements



Link for playlists:
   / @learningmonkey  


Link for our website: https://learningmonkey.in

Follow us on Facebook @   / learningmonkey  

Follow us on Instagram @   / learningmonkey1  

Follow us on Twitter @   / _learningmonkey  

Mail us @ [email protected]


On this page of the site you can watch the video online GROUP BY and HAVING in SQL || Lesson 82 || DBMS || Learning Monkey || with a duration of hours minute second in good quality, which was uploaded by the user Learning Monkey 29 December 2021, share the link with friends and acquaintances, this video has already been watched 893 times on youtube and it was liked by 24 viewers. Enjoy your viewing!