Demo SQL Database
Below is a demo SQL table that will be used in examples later in the article.
id | column1 | column2 |
---|---|---|
1 | 10 | 20 |
2 | 25 | 15 |
3 | 5 | 40 |
4 | 30 | 10 |
To create this table, write the following SQL queries:
CREATE TABLE SampleTable (
id INT PRIMARY KEY,
column1 INT,
column2 INT
);
INSERT INTO SampleTable (id, column1, column2)
VALUES
(1, 10, 20),
(2, 25, 15),
(3, 5, 40),
(4, 30, 10);
How to Find the Maximum of Multiple Columns in SQL
Finding the maximum value of multiple columns is one of the most common analytical tasks essential for making decisions and analyzing data. Using the MAX() function of SQL, users can find the maximum value in a single column. But to find the maximum value in multiple columns, users need to use other SQL statements like CASE or GREATEST.
This article covers the methods to find the max value of multiple columns in a SQL table.