Select

SELECT

SELECT returns rows from a table.

SELECT
    select_expr [ AS alias ] [, ...]
    FROM table_name
    [ WHERE where_expr ]
    [ GROUP BY group_expr ]
    [ TIMESERIES timeseries_expr ]
    [ ORDER BY order_by_expr ]
    [ LIMIT count ]

select_expr

Expressions that form the output rows. Standard modifiers (*,+,-,\,%) and groupings are supported. Aggregate functions can be used over columns.

The following aggregate functions are supported:

  • MIN
  • MAX
  • AVG
  • SUM
  • COUNT

table_name

The name of the table.

where_expr

The WHERE expression is a boolean expression used to filter rows from the result.

You may group ( ) boolean expressions together forming arbitrary expression trees using AND and OR.

Equality operators =, !=, and comparison operators >, >=, <, <= are supported.

Calculations may also be applied using standard operators such as (*,+,-,\,%).

group_by_expr

GROUP BY column_name [, ...]

Groups non-aggregate columns into groups of matching rows.

SELECT

timeseries_expr

TIMESERIES [ BY column_name ] amount_expr

TIMESERIES is an expression specific to Hyprcubd. It is used to generate a series of timestamps over the select query.

  • BY column_name is optional. The default column used is time.
  • amount_expr is a number followed by a unit.

Units:

  • ns, nanosecond
  • us, microsecond
  • ms, millisecond
  • s, second, SECOND
  • m, minute, MINUTE
  • h, hour, HOUR
  • d, day, DAY

Example

What is the average hourly temperature by city over the last day?

SELECT time, city, AVG(temp)
FROM temps
WHERE time >= '2020-04-27' and time < '2020-04-28'
GROUP BY city
TIMESERIES 1h
ORDER BY time

order_by_expr

ORDER BY column_name [, ...]

Performs a sort

limit

LIMIT count

Limit the number of rows