MAXIFS in SQL
MAXIFS returns the largest value among rows that meet conditions; in SQL it is MAX with a WHERE clause.
The Excel version
=MAXIFS(C:C, B:B, "West", D:D, ">="&DATE(2026,1,1))The SQL equivalent
This example assumes: sales(id bigint, region text, amount numeric, sale_date date). It is written in PostgreSQL syntax, and your table and column names will differ from these.
SELECT MAX(amount) AS largest_west_sale_2026
FROM sales
WHERE region = 'West'
AND sale_date >= DATE '2026-01-01';How it works
- The criteria become the WHERE clause, as in SUMIFS.
- MAX(amount) returns the largest remaining value; use MIN for MINIFS.
- To see the row that holds the maximum, not just the value, ORDER BY amount DESC LIMIT 1.
Where the results differ from Excel
- MAXIFS returns 0 when nothing matches; MAX returns null.
- MAX works on text and dates in SQL (alphabetical and latest), unlike MAXIFS, which is for numbers.
- Ties are not shown by either; use RANK if you need every row that shares the maximum.
Skip the query: ask in plain English
If you would rather not write SQL, type the question. SchemaChat turns it into SQL against your connected database or uploaded file, runs it, and shows the SQL and the figures it used so you can check the answer before you share it. Check that the result matches how your spreadsheet defines the number.
- What was the largest West region sale this year?
- Which sale was the biggest in each region?