Basic SELECT Syntax
SELECT with WHERE
SELECT DISTINCT
Eliminate duplicate rows from results:GROUP BY Queries
ORDER BY Sorting
sort by as an alias for order by.
See BI.SQL.pas:70 for implementation.
TOP and OFFSET
Pagination
Sub-Queries
TeeBI supports sub-queries in WHERE clauses:Aggregate Functions
Supported aggregation functions:count(*)- Count rowscount(Field)- Count non-null valuessum(Field)- Sum valuesaverage(Field)- Average valuesmin(Field)- Minimum valuemax(Field)- Maximum valuefirst(Field)- First valuelast(Field)- Last value
Date/Time Parts
Group by date/time parts:Year,Month,Day,Quarter,WeekHour,Minute,SecondWeekDay,DayOfYear
Expressions in Queries
Use expressions in SELECT, WHERE, and GROUP BY:TBISQL Class
The main SQL parser and executor class. See BI.SQL.pas:81.From Methods
Example Usage
TSQLParser Class
Low-level SQL parser. See BI.SQL.pas:27.Error Handling
Provide custom error handling:Field Name Escaping
Fields with spaces must be escaped with braces:Supported Keywords
SELECT- Select columns (optional, implied)DISTINCT- Eliminate duplicatesFROM- Source table (optional when single source)WHERE- Filter rowsGROUP BY- Group and aggregateORDER BY/SORT BY- Sort resultsHAVING- Filter after aggregationLIMIT- Maximum rowsOFFSET- Skip rowsTOP- Alternative to LIMIT (can be combined with OFFSET)
