From the course: Oracle Database 12c: Basic SQL

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using GROUP BY

Using GROUP BY - Oracle Database Tutorial

From the course: Oracle Database 12c: Basic SQL

Start my 1-month free trial

Using GROUP BY

- [Instructor] The group by sequel syntax which is often combined with certain aggregate functions such as COUNT MAX SUM MEAN or AVERAGE is used to group the result set from our query based on one or more columns. Let's see a very simple example of using group by in a select statement. In our example, we simply want to count how many employees have been assigned to each one of our departments. So in order to accomplish that we'll type select count and then inside parenthesis we'll just type the star character comma and department id from our employees table group by, this is where the new syntax comes into play, department id. Essentially telling oracle to count the number of rows in our table in groups. And we perform the group by using the department id column. So that you can see that we have six employees assigned to department id 100 and another six employees assigned to department id 30. Note they can also add an alias to the count syntax in my sequel query to make it more…

Contents