FROM bang
[WHERE dieukien];
Parameters :
Note :
Take a look and explore some examples of MAX functions in SQL Server.
Suppose, we have the following data table:
Example 1: Find the maximum number of posts in the table
SELECT MAX(Sobai)
FROM Quantrimang
WHERE Sobai < 100;
Result: 122
In this example we have the highest number of articles in a column in the Quantrimang table, where the number of posts is less than 100.
Example 2: Use GROUP BY
The following example finds the largest value of all records related to a large section, you will do the following:
SELECT Chuyenmuclon, MAX(Sobai) AS 'So bai nhieu nhat'
FROM Quantrimang
GROUP BY Chuyenmuclon;
Result:
Chuyenmuclon So bai nhieu nhat
Laptrinh 122
Mang xa hoi 165
Trinh duyet web 94
Previous article: Function FLOOR in SQL Server
Next lesson: MIN function in SQL Server