Examples

Complete worked examples, from basic selection to multi-constraint problems. Each one creates sample data, writes a query, and walks through the result.

Basic

Knapsack Problem

Select items to maximize value while staying within a weight limit. The classic optimization problem.

Binary Variables Single Constraint MAXIMIZE
View Example
Basic

Production Planning

Determine how many units of each product to manufacture within capacity constraints.

Integer Variables Row-Level Bounds MINIMIZE
View Example
Basic

Item Filtering

Select items matching specific criteria and ranges using BETWEEN and IN clauses.

Binary Variables BETWEEN Clause IN Clause
View Example
Intermediate

Diet Planning

Select meals to minimize cost while meeting nutritional requirements for protein, carbs, and fat.

Binary Variables Multiple Constraints Lower+Upper Bounds MINIMIZE
View Example
Intermediate

Multi-Variable Assignment

Assign workers to tasks with multiple decision variables per row and equality constraints.

Multiple Decision Variables Equality Constraints
View Example
Intermediate

Dynamic Constraints

Use scalar subqueries and CASE expressions to compute constraint bounds dynamically.

Scalar Subquery CASE Expression COUNT Simulation
View Example
Advanced

Portfolio Optimization

Select assets to maximize expected return while respecting risk limits and diversification rules.

Scalar Subquery CASE Expression Complex Coefficients
View Example
Advanced

Resource Scheduling

Assign resources to time slots across multiple tables using JOIN with decision variables.

JOIN Complex WHERE
View Example
Advanced

Multi-Period Planning

Plan production across multiple time periods with inventory and complex expressions.

Multiple Variables Complex Expressions Linearized Ratios
View Example

Ready to Build Your Own?

Check out the documentation for the complete syntax reference and learn more about the project.