Back to questions

Mean, Median, Mode

Medium

You are given a list of numbers representing how many emails each Microsoft Outlook user has in their inbox. Before the Product Management team can work on features related to inbox zero or bulk-deleting email, they simply want to know what the mean, median, and mode are for the number of emails.

Output the median, median and mode (in this order). Round the mean to the the closest integer and assume that there are no ties for mode.

### Table:

Column NameType
user_idinteger
email_countinteger

### Example Input:

user_idemail_count
123100
234200
345300
456200
567200

meanmedianmode
200200200

### Explanation

The mean is 200 which is calculated by taking the total number of emails as 1,000 (100 + 200 + 300 + 200 + 200) divided by 5 users.

The mode is 200, as there are 3 instances of this email count, meaning it is the most frequent instance.

The median is also 200 since if we order the dataset by email count, it is the value that separates higher half from the lower half of the values.

PostgreSQL 14

Refer friends to get bonus content & cool prizes.