Simple queries - Amazon Timestream

Simple queries

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

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

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

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

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