YouOracle
Simple Oracle
Pages
Home
About
Showing posts with label
SQL GROUP BY
.
Show all posts
Showing posts with label
SQL GROUP BY
.
Show all posts
How to use SQL GROUP BY?
GROUP BY keyword is used to group rows according to given columns.
Example:
Get average grade of each class students belong to.
SELECT studentClass, AVG(grade) FROM studentGrades GROUP BY
studentClass
How to use SQL HAVING?
HAVING keyword is used to filter rows returned by GROUP BY keyword. GROUP BY statement must be used in order to use HAVING to filter.
Example:
Select class score averages greater than the 60.
SELECT studentClass, AVG(grade) FROM studentGrades GROUP BY
studentClass HAVING
AVG(grade) > 60
Older Posts
Home
Subscribe to:
Comments (Atom)