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

Опубликовано: 29 Декабрь 2021
на канале: 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]


На этой странице сайта вы можете посмотреть видео онлайн GROUP BY and HAVING in SQL || Lesson 82 || DBMS || Learning Monkey || длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Learning Monkey 29 Декабрь 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 893 раз и оно понравилось 24 зрителям. Приятного просмотра!