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

Publicado em: 29 Dezembro 2021
no canal de: 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]


Nesta página do site você pode assistir ao vídeo on-line GROUP BY and HAVING in SQL || Lesson 82 || DBMS || Learning Monkey || duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Learning Monkey 29 Dezembro 2021, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 893 vezes e gostou 24 espectadores. Boa visualização!