SQL Bootcamp: Session 6 (Group by in SQL) | Where vs Having in SQL | SQL for Data Analytics

Publicado el: 01 enero 1970
en el canal de: TechiesAdda
53
1

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.


En esta página del sitio puede ver el video en línea SQL Bootcamp: Session 6 (Group by in SQL) | Where vs Having in SQL | SQL for Data Analytics de Duración hora minuto segunda en buena calidad , que subió el usuario TechiesAdda 01 enero 1970, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 53 veces y le gustó 1 a los espectadores. Disfruta viendo!