Professional Documents
Culture Documents
Fungsi-Fungsi Agregat
AVERAGE
avg()
MINIMUM
MAXIMUM
SUMMARY
COUNT
DISTINCT
Aggregate functions
nr
1
5
7
12
name
John
Sarah
Tom
Anne
salary
100
300
100
null
dept
A
C
A
C
SUM
SQL
select
sum(salary)
from E
Result
Sum
500
Relational
algebra
Fsum(salary)(E)
Note:
AVG
SQL
select
avg(salary)
from E
Result
avg
125
Relational
algebra
Favg(salary)(E)
Note:
MIN
SQL
select
min(salary)
from E
Result
min
100
Relational
algebra
Fmin(salary)(E)
Note:
MAX
SQL
select
max(salary)
from E
Result
max
300
Relational
algebra
Fmax(salary)(E)
Note:
COUNT
SQL
Result
select
count(salary)
from E
Count
3
Relational
algebra
Fcount(salary)(E)
Duplicates
are not
eliminated.
Null
Having
Pemakaian HAVING terkait dengan klausa GROUP BY. Kegunaannya adalah untuk menentukan kondisi
bagi GROUP BY. Kelompok yang memenuhi HAVING saja yang akan dihasilkan. Sebagai contoh, anda bisa
mencoba pernyataan sebagai berikut:
SELECT table.One FROM table WHERE table.Four=5 GROUP BY table.One HAVING count (table.Three)>4
Answer: table (Four = 5) G One F count(Three) count(Three) > 4 One