Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Select Grouped and Aggregated Data with SQL


    Another powerful SQL skill is understanding how to group rows together by column values. Once the data is grouped together, it can be difficult to understand how to actually work with the groupings. In this lesson, we will use the group by clause, as well as the count, sum, avg, min, and max aggregate functions.

    Counts with create date and first name example:

    select, u.create_date, first_name from Users us inner join (select count(create_date) as total, create_date from Users group by create_date) u on u.create_date = us.create_date;

    Min create date with first name example:

    select create_date, first_name from Users where create_date = (select min(create_date) from Users);

    Aggregate functions: