The following tables list every keyword valid in Luminesce SQL queries, with a short description and example of each. Most keywords are inherited from the SQLite dialect of SQL. Some are FINBOURNE extensions.
Keywords are not case-sensitive. They are reserved, so to use one as a column or table name, wrap it in [], for example select [Date], [Text] from @x. The exception is FORCE, which you can use as a name without brackets (new key words in the future will be like this whenever possible to avoid causing issues with existing queries that might have such words in them).
Query clauses
The building blocks of a SELECT statement. See Understanding the Luminesce SQL query syntax for more.
Keyword | Description | Example |
| Starts a query and lists the columns to return. |
|
| Names the provider, table variable or subquery to read from. |
|
| Keeps only the rows that match a condition. Also sets provider parameters. |
|
| With |
|
| Used in |
|
| Filters groups after |
|
| With |
|
| Sorts in ascending order (the default). |
|
| Sorts in descending order. |
|
| With |
|
| Used in |
|
| Used in |
|
| Returns at most the given number of rows. |
|
| Skips the given number of rows before returning any. |
|
| Removes duplicate rows, or duplicate values inside an aggregate function. |
|
| Keeps duplicate rows. Mostly used in |
|
| Names a column, table or window. Also sets the type in |
|
| Builds a table from literal rows. |
|
| Combines two results and removes duplicate rows. |
|
| Returns the rows that appear in both results. |
|
| Returns the rows in the first result that are not in the second. In |
|
| True if a subquery returns at least one row. |
|
| Changes a setting for the current query. See PRAGMAs. |
|
| With |
|
| Used in |
|
| Used in |
|
Joins
Luminesce supports inner, left, full and cross joins, but not right joins. See JOIN clauses.
Keyword | Description | Example |
| Combines rows from two sources. |
|
| Returns only the rows that match on both sides. This is the default join. |
|
| Returns every row from the left side, with nulls where the right side has no match. |
|
| Optional in |
|
| Returns every row from both sides, with nulls where either side has no match. |
|
| Pairs every row on the left with every row on the right. Also forms |
|
| Sets the join condition. |
|
| Joins on columns that have the same name on both sides. |
|
Operators and expressions
Text comparisons in Luminesce ignore case and accents unless you use COLLATE EXACT.
Keyword | Description | Example |
| True if both conditions are true. |
|
| True if either condition is true. |
|
| Reverses a condition. |
|
| True if a value is in a list, a subquery or a table variable. |
|
| True if a value is not in a list, a subquery or a table variable. |
|
| Compares two values, treating two nulls as equal. |
|
| The opposite of |
|
| True if a value is null. The SQLite shorthand |
|
| True if a value is not null. The SQLite shorthand |
|
| True if a value is in a range, including both ends. |
|
| True if a value is outside a range. |
|
| Matches a pattern, where |
|
| True if a value does not match a |
|
| Sets the character that makes |
|
| Matches a Unix-style pattern, where |
|
| True if a value does not match a |
|
| Matches a regular expression. See REGEXP. |
|
| True if a value does not match a regular expression. |
|
| Starts a conditional expression. |
|
| Gives a condition in a |
|
| Gives the result for a |
|
| Gives the result when no |
|
| Ends a |
|
| Converts a value to another type. |
|
| Compares text ignoring case, but not accents. |
|
| Compares text ignoring both case and accents. This is the default. |
|
| Compares text exactly, respecting case and accents. |
|
| A missing value. |
|
| The boolean value true. |
|
| The boolean value false. |
|
| The current date, in UTC. |
|
| The current time, in UTC. |
|
| The current date and time, in UTC. |
|
Window definitions
Used with OVER to define the rows that a window function works on. See the SQLite window functions documentation.
Keyword | Description | Example |
| Makes an aggregate or window function work over a window of rows. |
|
| With |
|
| Names a window definition so you can reuse it. |
|
| Limits the rows an aggregate function uses. |
|
| Defines the window frame as a number of rows. |
|
| Defines the window frame by a range of |
|
| Defines the window frame as a number of peer groups. |
|
| Makes the frame start at the first row, or end at the last row. |
|
| Counts the frame start back from the current row. |
|
| Counts the frame end on from the current row. |
|
| Used in |
|
| Used in |
|
| Leaves some rows out of the frame. |
|
| Used in |
|
| Used in |
|
| Used in |
|
FINBOURNE extensions
Keywords that Luminesce adds to SQLite.
Keyword | Description | Example |
| Starts a block of input for a direct provider. The block ends with |
|
| Ends a |
|
| Passes table or scalar variables into a direct provider. Unlike SQLite, it does not define common table expressions; use table variables instead. |
|
| Makes sure the named columns exist in a direct provider's result, even if it returns no rows. |
|
| With |
|
| Waits for everything before it to finish, plus an optional number of seconds. See WAIT. |
|
Types
The types you can use with TYPES to set column types. TYPES also accepts DATE, TIME and DATETIME. See Type conversion.
Keyword | Description | Example |
| Sets the types of the columns returned by the next |
|
| A 64-bit integer. |
|
| A 32-bit integer. |
|
| True or false. |
|
| A double-precision floating-point number. |
|
| A decimal number. |
|
| A string. |
|
Reserved keywords
These keywords are reserved but not currently used. To use one as a column or table name, wrap it in [].
Keyword | Description | Example |
| Reserved. |
|
| Reserved. |
|
| Reserved on its own. Use |
|
SQLite scalar functions
See the SQLite core functions documentation.
Keyword | Description | Example |
| Returns the absolute value of a number. |
|
| Reserved function. | |
| Returns the first argument that is not null. |
|
| Function form of the |
|
| Reserved function. | |
| Returns the second argument if the first is true, otherwise the third. |
|
| Returns the first argument if it is not null, otherwise the second. |
|
| Returns the position of the first occurrence of one string in another, or 0. |
|
| Returns the number of characters in a string. |
|
| Function form of the |
|
| Reserved function. | |
| Converts a string to lower case. |
|
| Removes spaces, or the given characters, from the start of a string. |
|
| With one argument, returns the largest value in a group. With several, returns the largest argument. |
|
| With one argument, returns the smallest value in a group. With several, returns the smallest argument. |
|
| Returns null if the two arguments are equal, otherwise the first. |
|
| Formats values into a string, like the C |
|
| Returns a value as an SQL literal. |
|
| Returns a random 64-bit integer. |
|
| Returns a blob of the given number of random bytes. |
|
| Replaces every occurrence of one string with another. |
|
| Rounds a number to the given number of decimal places. |
|
| Removes spaces, or the given characters, from the end of a string. |
|
| Returns the soundex code of a string. |
|
| Returns part of a string, from a start position and an optional length. |
|
| Removes spaces, or the given characters, from both ends of a string. |
|
| Returns the storage type of a value: |
|
| Returns the Unicode code point of the first character of a string. |
|
| Reserved function. | |
| Converts a string to upper case. |
|
| Reserved function. |
SQLite date and time functions
See the SQLite date and time functions documentation. DATE, TIME and DATETIME are also types you can use with TYPES.
Keyword | Description | Example |
| Returns a date as |
|
| Returns a time as |
|
| Returns a date and time as |
|
| Returns the Julian day number of a date. |
|
| Formats a date using a format string. |
|
SQLite aggregate functions
See the SQLite aggregate functions documentation. MAX and MIN are listed under scalar functions.
Keyword | Description | Example |
| Returns the average of the values that are not null. |
|
| Counts rows, or the values that are not null. |
|
| Joins values into one string, separated by commas or the given separator. |
|
| Returns the sum of the values, or null if there are none. |
|
| Like |
|
SQLite window functions
See the SQLite window functions documentation.
Keyword | Description | Example |
| Returns the number of the row in its partition, starting at 1. |
|
| Returns the rank of the row, with gaps after ties. |
|
| Returns the rank of the row, without gaps after ties. |
|
| Returns the relative rank of the row, from 0.0 to 1.0. |
|
| Returns the cumulative distribution of the row, from 0.0 to 1.0. |
|
| Splits the partition into N groups and returns the group number of the row. |
|
| Returns a value from an earlier row. |
|
| Returns a value from a later row. |
|
| Returns a value from the first row of the frame. |
|
| Returns a value from the last row of the frame. |
|
| Returns a value from the Nth row of the frame. |
|
SQLite extension functions
Maths, string and statistical functions from the SQLite extension library.
Keyword | Description | Example |
| Returns the standard deviation of the values. |
|
| Returns the variance of the values. |
|
| Returns the most common value. |
|
| Returns the median value. |
|
| Returns the lower quartile (25th percentile). |
|
| Returns the upper quartile (75th percentile). |
|
| Repeats a string the given number of times. |
|
| Returns the given number of characters from the start of a string. |
|
| Returns the given number of characters from the end of a string. |
|
| Reverses a string. |
|
| Capitalises the first letter of each word. |
|
| Pads a string on the left with spaces to the given length. |
|
| Pads a string on the right with spaces to the given length. |
|
| Pads a string on both sides with spaces to centre it in the given length. |
|
| Keeps only the characters that appear in a second string (case-sensitive). |
|
| Returns the position of one string in another, optionally starting from a given position. |
|
| Compares the soundex codes of two strings and returns 0 (not alike) to 4 (very alike). |
|
| Returns the natural logarithm. |
|
| Returns the base-10 logarithm. |
|
| Returns e raised to the given power. |
|
| Raises a number to a power. |
|
| Returns 1, 0 or -1 for a positive, zero or negative number. |
|
| Returns the square root. |
|
| Returns the square. |
|
| Rounds up to the next integer. |
|
| Rounds down to the next integer. |
|
SQLite JSON functions
See the SQLite JSON functions documentation and Converting to and from JSON.
Keyword | Description | Example |
| Checks that a string is valid JSON and returns it minified. |
|
| Builds a JSON array from its arguments. |
|
| Returns the number of elements in a JSON array. |
|
| Returns the value at a path in a JSON document. |
|
| Adds a value at a path, if nothing is there already. |
|
| Builds a JSON object from name and value pairs. |
|
| Merges one JSON object into another. |
|
| Converts a value to its JSON form. |
|
| Removes the values at the given paths. |
|
| Returns the type of a JSON value, such as |
|
| Returns 1 if a string is valid JSON, otherwise 0. |
|
| Aggregates values into a JSON array. |
|
| Aggregates name and value pairs into a JSON object. |
|
FINBOURNE general functions
Keyword | Description | Example |
Checks whether you have access to a resource in the FINBOURNE platform. |
| |
| Reserved function. | |
Stops the query with an error message. |
| |
Stops the query and returns the contents of a table variable as the result. |
| |
Sends a message to the query progress log. |
| |
Shows a fractional number of days as days, hours, minutes and seconds. |
| |
Converts a string in a non-standard format to a date. |
| |
Returns 1 if a value is a date, optionally in a given format, otherwise 0. |
| |
Converts a date in the given timezone to UTC. |
| |
Converts a date to an ISO 8601 string. |
| |
Converts a UTC date to the given timezone. |
| |
Converts a date from one timezone to another. |
| |
Returns 1 if a value is a number, otherwise 0. |
| |
Returns 1 if a value is an integer, otherwise 0. |
| |
Returns the Levenshtein distance between two strings. |
| |
Creates a hash of one or more values. Uses SHA256 by default. |
| |
Returns 1 if a string contains the given whole word, otherwise 0. |
| |
Returns 1 if a string contains a word starting with the given text, otherwise 0. |
| |
Returns 1 if any item in a CSV string equals a value, otherwise 0. |
| |
Returns 1 if any item in a CSV string is in a second CSV string, otherwise 0. |
| |
Returns 1 if every item in a CSV string equals a value, otherwise 0. |
| |
Returns 1 if every item in a CSV string is in a second CSV string, otherwise 0. |
| |
Returns the first part of a string that matches a regular expression. |
| |
Returns every part of a string that matches a regular expression, as a CSV list. |
| |
Returns the position of the first match of a regular expression. |
| |
Replaces every match of a regular expression. |
| |
| Reserved function. |
FINBOURNE statistical functions
See Statistical custom functions.
Keyword | Description | Example |
Returns the value at a percentile, given from 0.0 to 1.0. |
| |
Returns the cumulative product. |
| |
Returns the covariance of two columns. |
| |
Measures how lopsided the distribution of values is. |
| |
Measures how heavy the tails of the distribution are. |
| |
Returns the square root of the mean of the squared values. |
| |
Returns the harmonic mean. |
| |
Returns the geometric mean. |
| |
Returns the Shannon entropy of the values. |
| |
Returns the fraction of values less than or equal to the given value. |
| |
Returns the upper quartile minus the lower quartile. |
| |
Returns the difference between two quantiles. |
| |
Returns the linear correlation of two columns. |
| |
Returns the rank correlation of two columns. |
| |
Returns the mean of the squared differences between two columns. |
| |
Returns the mean of the absolute differences between two columns. |
| |
Returns the median of the absolute differences from the median. |
| |
Returns the mean absolute difference between two columns, as a fraction. |
| |
Returns the mean positive return divided by the mean negative return. |
| |
Returns the standard deviation of the returns below the mean. |
| |
Returns the fall from the highest value so far. Must be used in a window. |
| |
Returns the largest drawdown. |
| |
Returns the mean drawdown. |
| |
Returns the number of rows since the highest value so far. Must be used in a window. |
| |
Returns the longest drawdown length. |
| |
Returns the mean drawdown length. |
| |
Returns the standard deviation. Unlike |
| |
Returns the y intercept of a regression line fitted to two columns. |
| |
Returns the gradient of a regression line fitted to two columns. |
| |
Returns the standard error of the regression y intercept. |
| |
Returns the standard error of the regression gradient. |
| |
Turns a series of prices into a series of returns. |
| |
Turns a series of returns into a series of prices, from an initial price. |
| |
Returns the mean divided by the standard deviation. |
| |
Returns the standard deviation divided by the mean. |
| |
Returns the Minkowski distance between two columns, for a given power. |
| |
Returns the largest difference between two columns. |
| |
Returns the sum of the absolute differences between two columns. |
| |
Returns the straight-line distance between two columns. |
| |
Returns the Canberra distance between two columns. |
| |
Returns the Bray-Curtis distance between two columns. |
| |
Returns 1 minus the cosine of the angle between two columns. |
| |
Returns the fraction of predicted positives that are true positives. |
| |
Returns the fraction of true positives that were predicted. |
| |
Returns the F-score, weighting recall against precision by beta. |
| |
Returns how well one column predicts another. |
| |
Like |
|