-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Most/all relational database support GREATEST/LEAST, which accept an arbitrary number of parameters and return the greatest one. Note that unlike MAX/MIN, these aren't aggregate functions - they're just regular, non-aggregate variadic functions.
| Database | Functions | Notes |
|---|---|---|
| PostgreSQL | GREATEST/LEAST | |
| MySQL | GREATEST/LEAST | |
| MariaDB | GREATEST/LEAST | |
| SQLite | MAX/MIN | These are non-aggregate with multiple arguments |
| SQL Server | GREATEST/LEAST | SQL Server 2022 and above |
| Oracle | GREATEST/LEAST |
We can add EF.Functions.{Greatest,Least} in relational to support these. Note that these would be similar to Math.Max and Min, which we should also translate; however, a custom EF.Functions.Greatest would provide the following advantages:
- Support types for which Math.Max overloads don't exist (DateTime, string...)
- Allow passing more than 2 arguments without nesting Math.Max calls, since these aren't variadic and support only two arguments.
Originally requested e.g. in npgsql/efcore.pg#2866
Reactions are currently unavailable