Group By:- Group By clauses is used to groups rows based on the distinct values of the specified columns.
The syntax of the Group by clause is:-
Select column1, column2, column3, aggregate_function(expression )
From TableName Where (condition)
Group By Column1, column2, column3
For Example, suppose we have a table named EmpInfo which contains the information about the Id of the employee and the Id of the project and it contains the following data
Table:- EmpInfo
EmployeeId Projectid
————————–
1 1
2 2
3 2
4 2
5 3
Now suppose we want to know about the number of employee belonging to each project then we can use the group by clause as given below:-
select Projectid , count(employeeid) as NumberOfEmployee from EmpInfo Group by ProjectId
This query will give us the following result:-
ProjectId NumberOfEmployee
1 1
2 3
3 1
Having Clause :- Having clause is used in conjunction with the group clause by imposing a condition on the group by clause to further filter the records return by the group by clause.
Syntax for Having Clause:-
Select column1, column2, column3, aggregate_function(expression )
From TableName Where (condition)
Group By Column1, column2, column3
having aggregate_function(expression ) operator value
For example, suppose we want to know which project has more than 2 employee and the total no of their respective employees, we can use the following query
select Projectid , count(employeeid) as NumberOfEmployee from EmpInfo Group by ProjectId having count(employeeid) >2
The query will give us the following result:-
ProjectId NumberOfEmployee
2 3
In the above example, the Having clause further filter the result return by the Group By clause by imposing a condition that only those projectid will be shown who has more than 2 employee.
thank you
Pingback: cars for sale in durban
Pingback: agencia de viajes en managua
Pingback: gazebo
Pingback: agencia de viajes en managua
Pingback: jobcompass.com
Pingback: agencia de viajes en managua
Pingback: p385#https://bizhub24.pl
Pingback: Feed store near me 281-471-1171
Pingback: Free Gold Silver Stock Research 1 Bought by The Rothss Childss
Pingback: Business Analysis Shows Sexy Sex Doll is Potential Growth Worldwide
Pingback: click site
Pingback: Legit website developer in the USA
Pingback: 팩스 프린터 ë Œíƒˆ
Pingback: ต้องการ ที่ดิน ด่วน
Pingback: Totojitu
Pingback: Disponibilidad en Santo Domingo y a Nivel Nacional
Pingback: magnetic wallpaper
Pingback: 바카라사이트
Pingback: 카지노
Pingback: How to Earn Free Avios
Pingback: https://www.wasseem.org/
Pingback: 메이저사이트
Pingback: Bathroom fitter Wakefield
Pingback: Free Email Marketing Software 2019
Pingback: cardloan
Pingback: ธนาธร จึงรุ่งเรืองกิจ
Pingback: movies
Pingback: movies online
Pingback: karan johar
Pingback: Top Movies
Pingback: Movies1
Pingback: 11 10 2019
Pingback: w88top.com
Pingback: smotretonline2015.ru
Pingback: Serial smotret
Pingback: kinokrad
Pingback: kinokrad 2020
Pingback: ñïèñîê íîâûõ ôèëüìîâ
Pingback: Watch Tv Series Online
Pingback: casino
Pingback: Kinokrad 2019 Kinokrad Hd
Pingback: filmy-kinokrad
Pingback: kinokrad-2019
Pingback: filmy-2019-kinokrad
Pingback: serial
Pingback: cerialest.ru
Pingback: dorama hdrezka
Pingback: movies hdrezka
Pingback: HDrezka
Pingback: kinosmotretonline
Pingback: LostFilm HD 720
Pingback: trustedmdstorefy.com
Pingback: bofilm ñåðèàë
Pingback: bofilm
Pingback: 1 seriya
Pingback: Êîíñóëüòàöèÿ ïñèõîëîãà
Pingback: topedstoreusa.com
Pingback: hqcialismht.com
Pingback: viagramdtrustser.com
Pingback: lindamedic.com
Pingback: 4serial.com
Pingback: See-Season-1
Pingback: Evil-Season-1
Pingback: Evil-Season-2
Pingback: Evil-Season-3
Pingback: Evil-Season-4
Pingback: Dollface-Season-1
Pingback: Queer-Eye-We-re-in-Japan-Season-1
Pingback: 2020
Pingback: koma 2020