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 will be discussing some of the aggregate functions such as count, sum, average 1
Min and max 2
First is the count function 3
Count function will return the count of the expression that you have mentioned 4
For example if you want to find out the number of sales that you have done 5
You can count the number of sales lines that you have, to get the total number of sales that you are done 6
Or you want to find out the count of customers with name starting with A 7
Then again count function will help you 8
The syntax of count function is 9
You select the column names if you want 10
Count will be written as count and then you give the column name 11
Of the column of which you want the 12
Count 13
So it will count number of non null values in that column 14
After it has applied the condition so if you are mentioned any where clause 15
It will check the condition 16
And after that if there is any non null value in that particular column which were mentioned after the count 17
It will give that particular count 18
Let's look at some of the examples to understand this 19
So this first example where I have returned select count star from sales 20
It will 21
Go to the sales table 22
And it will 23
Look at all the records 24
And it will give back the count of all the rows in that particular table 25
Let it go and write this in the PG admin interface 26
Select 27
Count star 28
Remember that I put the star 29
Within the bracket 30
Whatever column name you want to mention you have to put it into bracket, from sales, sales is the table name 31
When I run this 32
I get a count of 33
9994 34
This is the total count but if you notice the column name is written as count 35
This may not make any sense to anyone who looks at this count that is why we will be using aliases 36
And mention 37
Count star as 38
The total count of sales something like that 39
So that we get the right column name 40
Now, Imagine if you want to find out 41
How many orders that particular customer has given 42
And how many products that particular customer has ordered 43
Go and look at the 44
Sales table 45
By just doing select star from sales 46
So for example, this first customer with customer ID CG 12520 47
It has two entries on the top those two entries have the same order ID 48
Which means it was one single order 49
In which two different products were ordered so the product ID in both these 50
Two rows is different 51
If I want to find out 52
Count of all the orders that this particular customer has given 53
And the count of different products that this customer has ordered 54
I start typing 55
Select 56
And select the count of 57
Order lines 58
So each separate order line is giving me the number of products that that particular customer has ordered 59
So I Name this as 60
Number of products ordered 61
Then I'll find out 62
Count of 63
Order IDs 64
Distinct order ID 65
If I do not write distinct 66
Repetitive order IDS will be 67
Will be counted multiple Times 68
As number of orders 69
And 70
This will be from the table 71
Sales 72
Where customer ID 73
Will be this CG 12520 74
CG12520 75
CG12520 76
Select this query and run it 77
You can see 78
The column names are the ones 79
That we provided 80
And 81
This particular customer 82
Ordered three times 83
He gave three orders 84
But 85
One or more of the orders has multiple products in it so 86
Total number of products ordered by this customer is 5 87
Next we'll look at how to use 88
Sum function
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.