Aggregate Operators
Significant extension of relational algebra.
COUNT (*)
COUNT ( [DISTINCT] A)
SUM ( [DISTINCT] A)
AVG ( [DISTINCT] A)
MAX (A)
MIN (A)
SELECT AVG (S.age)
FROM Sailors S
WHERE S.rating=10
SELECT COUNT (*)
FROM Sailors S
SELECT AVG ( DISTINCT S.age)
FROM Sailors S
WHERE S.rating=10
SELECT S.sname
FROM Sailors S
WHERE S.rating= (SELECT MAX(S2.rating)
FROM Sailors S2)
single column
SELECT COUNT (DISTINCT S.rating)
FROM Sailors S
WHERE S.sname=‘Bob’
Previous slide
Next slide
Back to first slide
View graphic version