Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
0 Now we know, how to use group by and how to use aggregate functions within group by 1
Now we want to put a filter or specify a condition 2
On this aggregate functions 3
How can we do that 4
This is done using the having clause 5
Having clause will restrict the groups of returned rows to only those whose condition is true 6
The syntax for having clause is 7
Select the column names or the aggregate function 8
From table 9
You can specify where conditions if you want to 10
Then you specify the group by 11
And Name the column with which you want to group 12
Then we specify the having condition 13
Let us see this example 14
IN this example 15
I want to find the number of customers 16
In each region 17
But I want to also put condition that I want only those regions 18
Which have more than 200 customers 19
To do this 20
I'll write select region 21
And count of customers 22
From the customer table 23
Group by region 24
And having count of customer ID greater than 200 25
This is the aggregate function 26
So let us go and write this in the PG admin 27
So, I'll select 28
The region and the count of customer ID 29
From 30
As customer count from 31
The table customer group by 32
Region 33
Having 34
Count of customer ID 35
Greater than 36
Greater than 200 37
This query will return me these two regions which have customers 38
more than 200 39
Now if you remember 40
We used to specify conditions in the where clause 41
Now we are specifying this condition in the having clause 42
What is the difference 43
The having Clause is used to specify conditions for the aggregate function 44
Whereas 45
Where was used to specific conditions on the 46
Non-aggregate columns 47
So for example in this query only 48
If, I want to put a condition that I want only count of customers whose name starts with A 49
Then I will write where 50
Customer name 51
Like A percent 52
So let us find out 53
Such customers, count of customer ID 54
As customer count 55
From customer 56
Where 57
Customer name 58
Like 59
A percent 60
Group by region 61
by region 62
Lets run this 63
this is the count of customers whose name 64
Starts with A in 65
These four different regions 66
I can put the having condition also 67
Having count of customer ID 68
Greater than 15, so if you look at this table below 2 of the field 69
Will go 70
And two will remain which are greater than 15 71
So, Two major differences, one where is written before group by and having his return after group by 72
Second 73
Having is used to put condition on aggregate functions whereas condition on non aggregate columns are put 74
Using the where clause
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.