Simple queries - Amazon Timestream

Simple queries

To get the 10 most recently added data points for a table:

SELECT * FROM <database_name>.<table_name> ORDER BY time DESC LIMIT 10

To get the 5 oldest data points for a specific measure:

SELECT * FROM <database_name>.<table_name> WHERE measure_name = ‘<measure_name>’ ORDER BY time ASC LIMIT 5

To manipulate nanosecond granularity timestamps:

SELECT now() AS time_now , now() - (INTERVAL '12' HOUR) AS twelve_hour_earlier -- Compatibility with ANSI SQL , now() - 12h AS also_twelve_hour_earlier -- Convenient time interval literals , ago(12h) AS twelve_hours_ago -- More convenience with time functionality , bin(now(), 10m) AS time_binned -- Convenient time binning support , ago(50ns) AS fifty_ns_ago -- Nanosecond support , now() + (1h + 50ns) AS hour_fifty_ns_future