Query Alignment Mode

In addition, IoTDB supports another result set format: ALIGN BY DEVICE.

align by device

The ALIGN BY DEVICE indicates that the deviceId is considered as a column. Therefore, there are totally limited columns in the dataset.

NOTE:

1.You can see the result of ‘align by device’ as one relational table, Time + Device is the primary key of this Table.

2.The result is order by Device firstly, and then by Time order.

The SQL statement is:

  1. select * from root.ln.** where time <= 2017-11-01T00:01:00 align by device;

The result shows below:

  1. +-----------------------------+-----------------+-----------+------+--------+
  2. | Time| Device|temperature|status|hardware|
  3. +-----------------------------+-----------------+-----------+------+--------+
  4. |2017-11-01T00:00:00.000+08:00|root.ln.wf01.wt01| 25.96| true| null|
  5. |2017-11-01T00:01:00.000+08:00|root.ln.wf01.wt01| 24.36| true| null|
  6. |1970-01-01T08:00:00.001+08:00|root.ln.wf02.wt02| null| true| v1|
  7. |1970-01-01T08:00:00.002+08:00|root.ln.wf02.wt02| null| false| v2|
  8. |2017-11-01T00:00:00.000+08:00|root.ln.wf02.wt02| null| true| v2|
  9. |2017-11-01T00:01:00.000+08:00|root.ln.wf02.wt02| null| true| v2|
  10. +-----------------------------+-----------------+-----------+------+--------+
  11. Total line number = 6
  12. It costs 0.012s

Ordering in ALIGN BY DEVICE

ALIGN BY DEVICE mode arranges according to the device first, and sort each device in ascending order according to the timestamp. The ordering and priority can be adjusted through ORDER BY clause.

For details and examples, see the document Order By.