MIN_IF (Lakehouse v1)
The suffix _IF can be appended to the name of any aggregate function. In this case, the aggregate function accepts an extra argument – a condition.
Analyze Syntax
Section titled “Analyze Syntax”func.min_if(<column>, <cond>)Analyze Examples
Section titled “Analyze Examples”func.min_if(table.budget, table.departing=='IT').alias('min_it_budget')
| min_it_budget ||---------------|| 2000 |SQL Syntax
Section titled “SQL Syntax”MIN_IF(<column>, <cond>)SQL Examples
Section titled “SQL Examples”Create a Table and Insert Sample Data
CREATE TABLE project_budgets ( id INT, project_id INT, department VARCHAR, budget FLOAT);
INSERT INTO project_budgets (id, project_id, department, budget)VALUES (1, 1, 'HR', 1000), (2, 1, 'IT', 2000), (3, 1, 'Marketing', 3000), (4, 2, 'HR', 1500), (5, 2, 'IT', 2500);Query Demo: Find Minimum Budget for IT Department
SELECT MIN_IF(budget, department = 'IT') AS min_it_budgetFROM project_budgets;Result
| min_it_budget ||---------------|| 2000 |