SQLite等同于PostgreSQL的GREATEST函数 [英] SQLite equivalent of PostgreSQL's GREATEST function

查看:181
本文介绍了SQLite等同于PostgreSQL的GREATEST函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PostgreSQL有一个有用的功能,叫做 GREATEST 。它会返回此处中记录的最大值。

PostgreSQL has a useful function called GREATEST. It returns the largest value of those passed to it as documented here.

SQLite中是否有等效项?

Is there any equivalent in SQLite?

请注意,我只需要使用它来处理两个参数。

推荐答案

SELECT MAX(1,2,..)

ref : http://www.sqlite.org/lang_corefunc.html


max(X,Y,...)

max(X,Y,...)

多参数max()函数返回具有最大值的参数,如果任何参数为NULL,则返回NULL。多参数max()函数从左至右搜索其参数,以定义一个定义整理函数的参数,并将该整理函数用于所有字符串比较。如果max()的参数均未定义整理函数,则使用BINARY整理函数。请注意,当max()具有2个或更多参数时,它是一个简单函数,但如果仅给出一个参数,则它作为一个聚合函数。

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函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆