From the course: PostgreSQL: Advanced Queries
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Find the most frequent value within a dataset with MODE - PostgreSQL Tutorial
From the course: PostgreSQL: Advanced Queries
Find the most frequent value within a dataset with MODE
- [Instructor] The mode of a dataset is the value that occurs the most often, and it's another way to understand the central tendency of the data. PostgreSQL includes a mode function that finds this value, but its usage comes with a very large warning that you need to be aware of. Let's first find the mode of our height data, and then take a look at the problem with the calculation. The mode function itself doesn't take any arguments, but, like percentile, the mode function is another ordered-set aggregate function, so it uses the within group order by syntax. I want to find the mode of our height inches column and we'll pull that column from the public dot people heights table. Now, if we don't include a group by clause in this query, it'll simply find the most frequently occurring value within the entire table column. If I execute the query, the result tells me that 66.17 inches is the most common height. Now that may be…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Calculate the median value of a dataset6m 25s
-
(Locked)
Calculate the first and third quartiles of a dataset5m 47s
-
(Locked)
Find the most frequent value within a dataset with MODE2m 57s
-
(Locked)
Determine the range of values within a dataset2m 13s
-
(Locked)
Solution: Retrieve statistics of a dataset with groups4m 57s
-
(Locked)
-
-
-
-