Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Database Systems - Aggregate Functions COUNT SUM MIN MAX AVG and Using GROUP BY
Play lesson

Database Systems with SQL - Full Course - Database Systems - Aggregate Functions COUNT SUM MIN MAX AVG and Using GROUP BY

5.0 (0)
6 learners

What you'll learn

This course includes

  • 4.5 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

There are some useful aggregate functions in MySQL that you can use with a group of values. COUNT() – counts the number of rows MIN() – gets the minimum value MAX() – gets the maximum value SUM() – sums up the values AVG() – calculates the average of the values SELECT COUNT(*) FROM Movie WHERE Rating = ’R’; SELECT MAX(FinalExamGrade) FROM Student; SELECT AVG(FinalExamGrade) FROM Student; The GROUP BY clause is usually used along with aggregate functions, which groups rows with matching values into a set of summary rows, with one row for each group. SELECT ReleaseYear, COUNT(*) FROM Movie GROUP BY ReleaseYear; ORDER BY ReleaseYear; You can order the results using ORDER BY also. Place the GROUP BY clause before the ORDER BY clause and after the optional WHERE clause. To filter the group results, use the HAVING clause. Place the HAVING clause after the GROUP BY clause but before the optional ORDER BY clause. SELECT ReleaseYear, Title, COUNT(*) FROM Movie GROUP BY ReleaseYear, Title HAVING COUNT(*) GREATER_THAN_OR_EQUAL_TO 2; SELECT Name, Team, MAX(Points) FROM BasketballPlayer GROUP BY Name, Team, HAVING MAX(Points) GREATER_THAN 30 ORDER BY Name, MAX(Points); There are additional functions that you can use in your SQL query. Numeric functions: String functions Date and time functions: Subscribe to Appficial for more programming videos coming soon. Also, don't forget to click LIKE and comment on the video if it helped you out!

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere