Mean and Mode in SQL Server
Mean is the average of the given data set calculated by dividing the total sum by the number of values in data set.
Example:
Input: 1, 2, 3, 4, 5 Output: 3 Explanation: sum = 1 + 2 + 3 + 4 + 5 = 15 number of values = 5 mean = 15 / 5 = 3
Query to find mean in the table
SELECT Avg(Column_Name) FROM Table_Name
Example:
Creating Table:

Table Content:

Query to find Mean:

Mode of a data set is the value that appears most frequently in a series of data.
Example:
Input: 1, 2, 2, 3, 4, 4, 4, 5, 5, 6 Output: 4 Explanation: 2 occurs 2 times, 5 occurs 2 times 4 occurs 3 times and rest other occurs 1 time So, 4 occurs most frequently and is thus the output.
Query to find mode in the table
SELECT TOP 1 Column_Name FROM Table_name GROUP BY [Column_Name] ORDER BY COUNT(*) DESC
Example:
Creating Table:

Table Content:

Query to find Mode:

Recommended Posts:
- SQL SERVER | IN Condition
- SQL Server Identity
- SQL Server | SERVERPROPERTY()
- Comparisons between Oracle vs SQL Server
- Difference between MySQL and MS SQL Server
- SQL Server | STUFF() Function
- Allow only alphabets in column in SQL Server
- SQL SERVER | Conditional Statements
- SQL Server Mathematical functions (SQRT, PI, SQUARE, ROUND, CEILING & FLOOR)
- Count the number of a special day between two dates by using PL/SQL
- MySQLi Procedural Functions
- MySQL | CONNECTION_ID( ) Function
- MySQL | CAST( ) Function
- MySQL | SESSION_USER( ) Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

