Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL SQLITE MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST DART PLAYWRIGHT TOOLS MATH SHEETS POWER BI

SQLite Tutorial

SQLite HOME SQLite Intro SQLite Get Started

SQLite SQL

SQLite SQL SQLite SELECT SQLite SELECT DISTINCT SQLite WHERE SQLite ORDER BY SQLite AND SQLite OR SQLite NOT SQLite INSERT INTO SQLite NULL Values SQLite UPDATE SQLite DELETE SQLite LIMIT SQLite Aggregate SQLite MIN() and MAX() SQLite COUNT() SQLite SUM() SQLite AVG() SQLite LIKE SQLite Wildcards SQLite GLOB SQLite IN SQLite BETWEEN SQLite Aliases SQLite Joins SQLite INNER JOIN SQLite LEFT JOIN SQLite RIGHT JOIN SQLite FULL JOIN SQLite CROSS JOIN SQLite Self Join SQLite UNION SQLite UNION ALL SQLite INTERSECT and EXCEPT SQLite GROUP BY SQLite HAVING SQLite EXISTS SQLite Subqueries SQLite INSERT INTO SELECT SQLite CASE SQLite NULL Functions SQLite Comments SQLite Operators

SQLite Advanced

SQLite UPSERT SQLite RETURNING SQLite WITH (CTE) SQLite Window Functions SQLite JSON

SQLite Database

SQLite Create DB SQLite Attach DB SQLite Create Table SQLite Drop Table SQLite Alter Table SQLite Data Types SQLite STRICT Tables SQLite Constraints SQLite NOT NULL SQLite UNIQUE SQLite PRIMARY KEY SQLite FOREIGN KEY SQLite CHECK SQLite DEFAULT SQLite AUTOINCREMENT SQLite Generated Columns SQLite Create Index SQLite Views SQLite Triggers SQLite Dates SQLite Transactions SQLite PRAGMA SQLite Injection

SQLite Tools

SQLite Command Line SQLite Import and Export SQLite with Python

SQLite References

SQLite Functions

SQLite Exercises

SQLite Editor SQLite Quiz SQLite Exercises

SQLite Functions


Share

SQLite Functions Reference

SQLite has many built in functions. This reference contains the string, numeric, date, aggregate, window, JSON and advanced functions.

Click a function to see its syntax, and examples you can try.


SQLite String Functions

FunctionDescription
CHARReturns a text made from Unicode code points
CONCATAdds two or more texts together
CONCAT_WSAdds two or more texts together, with a separator
FORMATFormats values into a text, with format codes like %s and %.2f
GLOBChecks if a text matches a pattern, with case sensitivity
HEXReturns the hexadecimal text of a value
INSTRReturns the position of the first occurrence of a text in another text
LENGTHReturns the number of characters in a text
LIKEChecks if a text matches a pattern, without case sensitivity
LOWERConverts a text to lower case
LTRIMRemoves characters from the start of a text
OCTET_LENGTHReturns the number of bytes in a text
QUOTEReturns a value written as an SQL literal
REPLACEReplaces all occurrences of a text with another text
RTRIMRemoves characters from the end of a text
SUBSTRReturns a part of a text
TRIMRemoves characters from the start and the end of a text
UNHEXTurns a hexadecimal text into a blob
UNICODEReturns the Unicode code point of the first character in a text
UPPERConverts a text to upper case


SQLite Numeric Functions

FunctionDescription
ABSReturns the absolute value of a number
ACOSReturns the arc cosine of a number
ACOSHReturns the hyperbolic arc cosine of a number
ASINReturns the arc sine of a number
ASINHReturns the hyperbolic arc sine of a number
ATANReturns the arc tangent of a number
ATAN2Returns the arc tangent of two numbers
ATANHReturns the hyperbolic arc tangent of a number
CEILRounds a number up to the nearest integer
COSReturns the cosine of a number
COSHReturns the hyperbolic cosine of a number
DEGREESConverts radians to degrees
EXPReturns e raised to the power of a number
FLOORRounds a number down to the nearest integer
LNReturns the natural logarithm of a number
LOGReturns the base 10 logarithm of a number, or the logarithm to another base
LOG10Returns the base 10 logarithm of a number
LOG2Returns the base 2 logarithm of a number
MODReturns the remainder of a division
PIReturns the value of pi
POWReturns a number raised to the power of another number
RADIANSConverts degrees to radians
RANDOMReturns a random integer
RANDOMBLOBReturns a blob with random bytes
ROUNDRounds a number to a given number of decimals
SIGNReturns the sign of a number: -1, 0 or 1
SINReturns the sine of a number
SINHReturns the hyperbolic sine of a number
SQRTReturns the square root of a number
TANReturns the tangent of a number
TANHReturns the hyperbolic tangent of a number
TRUNCRemoves the decimals of a number

SQLite Date Functions

FunctionDescription
DATEReturns a date, as YYYY-MM-DD
DATETIMEReturns a date and time, as YYYY-MM-DD HH:MM:SS
JULIANDAYReturns the Julian day number of a date
STRFTIMEFormats a date, with format codes like %Y and %m
TIMEReturns a time, as HH:MM:SS
TIMEDIFFReturns the difference between two dates, as a text
UNIXEPOCHReturns the number of seconds since 1970-01-01

SQLite Aggregate Functions

FunctionDescription
AVGReturns the average value of an expression
COUNTReturns the number of rows
GROUP_CONCATJoins the values in a group into one text
MAXReturns the largest value
MINReturns the smallest value
STRING_AGGJoins the values in a group into one text, with a separator
SUMReturns the sum of the values
TOTALReturns the sum of the values, as a decimal number

SQLite Window Functions

FunctionDescription
CUME_DISTReturns the cumulative distribution of each row
DENSE_RANKGives each row a rank, without gaps
FIRST_VALUEReturns the value from the first row in the window frame
LAGReturns a value from a row before the current row
LAST_VALUEReturns the value from the last row in the window frame
LEADReturns a value from a row after the current row
NTH_VALUEReturns the value from a given row in the window frame
NTILESplits the rows into a number of groups
PERCENT_RANKReturns the relative rank of each row, from 0 to 1
RANKGives each row a rank, with gaps after equal values
ROW_NUMBERGives each row a number, starting with 1

SQLite JSON Functions

FunctionDescription
JSONChecks that a text is valid JSON, and returns it minified
JSON_ARRAYCreates a JSON array from values
JSON_ARRAY_LENGTHReturns the number of items in a JSON array
JSON_EACHReturns one row for each item in a JSON array or object
JSON_EXTRACTReturns a value from a JSON text
JSON_GROUP_ARRAYTurns the values in a group into a JSON array
JSON_GROUP_OBJECTTurns the names and values in a group into a JSON object
JSON_INSERTAdds values to a JSON text, but does not change existing values
JSON_OBJECTCreates a JSON object from names and values
JSON_PATCHMerges two JSON objects
JSON_QUOTEReturns an SQL value written as JSON
JSON_REMOVERemoves values from a JSON text
JSON_REPLACEChanges existing values in a JSON text, but does not add new values
JSON_SETAdds or changes values in a JSON text
JSON_TREEReturns one row for each value in a JSON text, also nested values
JSON_TYPEReturns the type of a JSON value
JSON_VALIDChecks if a text is valid JSON

SQLite Advanced Functions

FunctionDescription
CHANGESReturns the number of rows changed by the last INSERT, UPDATE or DELETE
COALESCEReturns the first value that is not NULL
IFNULLReturns another value if a value is NULL
IIFReturns one value if a condition is true, and another value if not
LAST_INSERT_ROWIDReturns the rowid of the last inserted row
NULLIFReturns NULL if two values are equal
SQLITE_VERSIONReturns the version of SQLite
TOTAL_CHANGESReturns the number of rows changed since the connection was opened
TYPEOFReturns the storage class of a value
ZEROBLOBReturns a blob with a number of zero bytes


Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by W3Schools. All Rights Reserved. W3Schools is Powered by W3.CSS.