SQLite 相当于 PostgreSQL 的 GREATEST 函数

标签 sql sqlite postgresql

PostgreSQL 有一个很有用的函数叫做 GREATEST。它返回传递给它的最大值,如记录 here .

SQLite 中是否有任何等效项?

请注意,我只需要它处理 2 个参数。

最佳答案

选择最大值(1,2,..)

引用:https://sqlite.org/lang_corefunc.html#maxoreunc

max(X,Y,...)

The multi-argument max() function returns the argument with the maximum value, or return NULL if any argument is NULL. The multi-argument max() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to max() define a collating function, then the BINARY collating function is used. Note that max() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument.

关于SQLite 相当于 PostgreSQL 的 GREATEST 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2166690/

相关文章:

sql - 根据同一表中的行计算 SQL 存储过程中的总计

sql - sql pre 和deploy 是否在一个 session 中运行

java - SQLite:java.sql.SQLException:结果集是TYPE_FORWARD_ONLY?

android - 从 Android SQLite 游标中删除行

mysql - 连接表中没有行引用其连接的表中的任何行

mysql - sql计算我没有解决

macos - 从 chat.db 恢复 OS X iMessages 历史记录

sql - 如何将字符串中的值分离到postgresql中的列中?

java - Hibernate 期望序列而不是 postgres 的表

python - 1.5 中的 Django 日期时间查询集