Files
mindsdb--minds/docs/mindsdb_sql/sql_support/case-when.mdx
2024-11-12 17:04:46 +01:00

20 lines
582 B
Plaintext

---
title: The CASE WHEN Statement
sidebarTitle: CASE WHEN
---
MindsDB supports standard SQL syntax, including the `CASE WHEN` statement.
The `CASE WHEN` statement is used for conditional logic within queries. It evaluates conditions and returns specific values based on whether each condition is true or false, allowing for conditional output within `SELECT`, `WHERE`, and other clauses.
```sql
SELECT
CASE
WHEN a=1 THEN a+b
WHEN 1+2=b*2 THEN 0
WHEN (a+b>2 or b<c+3) AND a>b THEN b
ELSE c
END
FROM table_name;
```