Complete Theory and Video Script:
In SQL, the GROUP BY clause is used to group rows that have the same values in one or more columns.
It is often used in conjunction with aggregate functions such as COUNT, SUM, AVG, MAX, and MIN to
summarize or perform calculations on the grouped data.
------Create Table-----------
create table orders
(
Order_id int primary key not null,
customer_id int,
product_name varchar(20),
order_date date
);
go
---------Insert Data-------
insert into orders
values
(1,101,'A','2023-05-01')
,(2,102,'B','2023-05-01')
,(3,102,'A','2023-05-02')
,(4,103,'C','2023-05-03')
,(5,103,'D','2023-05-04')
,(6,104,'E','2023-05-05')
----------Check Data (Select)
Select * from Orders
-----------------------------
Select
count(order_id) as Order_Count
,customer_id
from orders
Group by customer_id
-------------------Where vs Having-----------
Select * from Orders
where order_date (Greater than sign here) '2023-05-01'
-----------------------
Select
count(order_id) as Order_Count
,customer_id
from orders
Group by customer_id
having count(order_id) (Greater than sign here) 1
--------------------NOTE------------------
Replace (Greater than sign here) by the sign, i have limitatio.
Because Youtube doesn't allow that sign in description.
Nesta página do site você pode assistir ao vídeo on-line SQL Bootcamp: Session 6 (Group by in SQL) | Where vs Having in SQL | SQL for Data Analytics duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário TechiesAdda 01 Janeiro 1970, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 53 vezes e gostou 1 espectadores. Boa visualização!