From the course: SQL for Statistics Essential Training

Unlock the full course today

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

Mode

Mode - PostgreSQL Tutorial

From the course: SQL for Statistics Essential Training

Start my 1-month free trial

Mode

- [Instructor] Let's look at another function that gives us information about the relationship between values and rows. The Mode function tells us the most frequently occurring value in a group of rows. For example, we might wonder what the most common number of employees on a shift is in any given month. We can build a query starting with a mode calculation. We'll do that by calling the Mode function, and then specifying within Group, and then specifying an Order By over a column. And the column we're interested is the number of employees per shift. So, this statement will give us a column that specifies the mode. So, let's give it an alias, we'll call it emp mode for the mode of employees. Now, let's flesh out the Select statement. Let's start with select. And we want to work with month of year. So, we'll specify that. And we need to specify where we're getting this data. And of course, that's from the store sales table. And we'll want to group by the month of year. And we do that…

Contents