📄 lang_expr.html
字号:
<tr><td valign="top" align="right">max(<i>X</i>,<i>Y</i>,...)</td><td valign="top">Return the argument with the maximum value. Argumentsmay be strings in addition to numbers. The maximum value is determinedby the usual sort order. Note that <b>max()</b> is a simple function whenit has 2 or more arguments but converts to an aggregate function if givenonly a single argument.</td></tr><tr><td valign="top" align="right">min(<i>X</i>,<i>Y</i>,...)</td><td valign="top">Return the argument with the minimum value. Argumentsmay be strings in addition to numbers. The minimum value is determinedby the usual sort order. Note that <b>min()</b> is a simple function whenit has 2 or more arguments but converts to an aggregate function if givenonly a single argument.</td></tr><tr><td valign="top" align="right">nullif(<i>X</i>,<i>Y</i>)</td><td valign="top">Return the first argument if the arguments are different, otherwise return NULL.</td></tr><tr><td valign="top" align="right">quote(<i>X</i>)</td><td valign="top">This routine returns a string which is the value ofits argument suitable for inclusion into another SQL statement.Strings are surrounded by single-quotes with escapes on interior quotesas needed. BLOBs are encoded as hexadecimal literals.The current implementation of <a href="lang_vacuum.html">VACUUM</a> uses this function. The functionis also useful when writing triggers to implement undo/redo functionality.</td></tr><tr><td valign="top" align="right">random(*)</td><td valign="top">Return a pseudo-random integerbetween -9223372036854775808 and +9223372036854775807.</td></tr><tr><td valign="top" align="right"><a name="replaceFunc"></a>replace(<i>X</i>,<i>Y</i>,<i>Z</i>)</td><td valign="top">Return a string formed by substituting string <i>Z</i> forevery occurrance of string <i>Y</i> in string <i>X</i>. The BINARYcollating sequence is used for comparisons.</td></tr><tr><td valign="top" align="right"><a name="randomblobFunc"></a>randomblob(<i>N</i>)</td><td valign="top">Return a <i>N</i>-byte blob containing pseudo-random bytes.<i>N</i> should be a postive integer.</td></tr><tr><td valign="top" align="right">round(<i>X</i>)<br>round(<i>X</i>,<i>Y</i>)</td><td valign="top">Round off the number <i>X</i> to <i>Y</i> digits to theright of the decimal point. If the <i>Y</i> argument is omitted, 0 is assumed.</td></tr><tr><td valign="top" align="right"><a name="rtrimFunc"></a>rtrim(<i>X</i>)<br>rtrim(<i>X</i>,<i>Y</i>)</td><td valign="top">Return a string formed by removing any and allcharacters that appear in <i>Y</i> from the right side of <i>X</i>.If the <i>Y</i> argument is omitted, spaces are removed.</td></tr><tr><td valign="top" align="right">soundex(<i>X</i>)</td><td valign="top">Compute the soundex encoding of the string <i>X</i>.The string "?000" is returned if the argument is NULL.This function is omitted from SQLite by default.It is only available the -DSQLITE_SOUNDEX=1 compiler optionis used when SQLite is built.</td></tr><tr><td valign="top" align="right">sqlite_version(*)</td><td valign="top">Return the version string for the SQLite librarythat is running. Example: "2.8.0"</td></tr><tr><td valign="top" align="right"> substr(<i>X</i>,<i>Y</i>,<i>Z</i>)<br> substr(<i>X</i>,<i>Y</i>)</td><td valign="top">Return a substring of input string <i>X</i> that beginswith the <i>Y</i>-th character and which is <i>Z</i> characters long.If <i>Z</i> is omitted then all character through the end of the stringare returned.The left-most character of <i>X</i> is number 1. If <i>Y</i> is negativethe the first character of the substring is found by counting from theright rather than the left. If <i>X</i> is stringthen characters indices refer to actual UTF-8 characters. If<i>X</i> is a BLOB then the indices refer to bytes.</td></tr><tr><td valign="top" align="right"><a name="trimFunc"></a>trim(<i>X</i>)<br>trim(<i>X</i>,<i>Y</i>)</td><td valign="top">Return a string formed by removing any and allcharacters that appear in <i>Y</i> from both ends of <i>X</i>.If the <i>Y</i> argument is omitted, spaces are removed.</td></tr><tr><td valign="top" align="right">typeof(<i>X</i>)</td><td valign="top">Return the type of the expression <i>X</i>. The only return values are "null", "integer", "real", "text", and "blob".SQLite's type handling is explained in <a href="datatype3.html">Datatypes in SQLite Version 3</a>.</td></tr><tr><td valign="top" align="right">upper(<i>X</i>)</td><td valign="top">Return a copy of input string <i>X</i> converted to allupper-case letters. The implementation of this function uses the C libraryroutine <b>toupper()</b> which means it may not work correctly on UTF-8 strings.</td></tr><tr><td valign="top" align="right">zeroblob(<i>N</i>)</td><td valign="top"><a name="zeroblob"></a>Return a BLOB consisting of N bytes of 0x00. SQLitemanages these zeroblobs very efficiently. Zeroblobs can be used toreserve space for a BLOB that is later written using <a href="c3ref/blob_open.html">incremental BLOB I/O</a>.</td></tr></table><b>Date And Time Functions</b><p>Date and time functions are documented in the <a href="http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions">SQLite Wiki</a>.</p><a name="aggregatefunctions"></a><b>Aggregate Functions</b><p>The aggregate functions shown below are available by default. Additionalaggregate functions written in C may be added using the <a href="c3ref/create_function.html">sqlite3_create_function()</a></a>API.</p><p>In any aggregate function that takes a single argument, that argumentcan be preceeded by the keyword DISTINCT. In such cases, duplicateelements are filtered before being passed into the aggregate function.For example, the function "count(distinct X)" will return the numberof distinct values of column X instead of the total number of non-nullvalues in column X.</p><table border=0 cellpadding=10 class="pdf_functions"><tr><td valign="top" align="right" width=120>avg(<i>X</i>)</td><td valign="top">Return the average value of all non-NULL <i>X</i> within agroup. String and BLOB values that do not look like numbers areinterpreted as 0.The result of avg() is always a floating point value even if allinputs are integers. </p></td></tr><tr><td valign="top" align="right">count(<i>X</i>)<br>count(*)</td><td valign="top">The first form return a count of the number of timesthat <i>X</i> is not NULL in a group. The second form (with no argument)returns the total number of rows in the group.</td></tr><tr><td valign="top" align="right">group_concat(<i>X</i>)<br>group_concat(<i>X</i>,<i>Y</i>)</td><td valign="top">The result is a string which is the concatenation ofall non-NULL values of <i>X</i>. If parameter <i>Y</i> is the separatorbetween instances of <i>X</i>. A comma (",") is used as the separatorif <i>Y</i> is omitted.</td></tr><tr><td valign="top" align="right">max(<i>X</i>)</td><td valign="top">Return the maximum value of all values in the group.The usual sort order is used to determine the maximum.</td></tr><tr><td valign="top" align="right">min(<i>X</i>)</td><td valign="top">Return the minimum non-NULL value of all values in the group.The usual sort order is used to determine the minimum. NULL is only returnedif all values in the group are NULL.</td></tr><tr><td valign="top" align="right">sum(<i>X</i>)<br>total(<i>X</i>)</td><td valign="top">Return the numeric sum of all non-NULL values in the group. If there are no non-NULL input rows then sum() returns NULL but total() returns 0.0. NULL is not normally a helpful result for the sum of no rows but the SQL standard requires it and most other SQL database engines implement sum() that way so SQLite does it in the same way in order to be compatible. The non-standard total() function is provided as a convenient way to work around this design problem in the SQL language.</p> <p>The result of total() is always a floating point value. The result of sum() is an integer value if all non-NULL inputs are integers. If any input to sum() is neither an integer or a NULL then sum() returns a floating point value which might be an approximation to the true sum.</p> <p>Sum() will throw an "integer overflow" exception if all inputs are integers or NULL and an integer overflow occurs at any point during the computation. Total() never throws an exception.</p></tr></table><hr><small<i>This page last modified 2007/12/20 21:09:25 UTC</i></small></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -