How can I modify this query to dynamo db query, i am not able to find the examples on aggregate functions and also date operations in dynamo db..
SELECT DATE(`date`) AS day ,SUM(`power`) AS power
FROM `ogm`
WHERE `id`!=0
AND DATE(`date`)>=DATE(NOW()) - INTERVAL 31 DAY GROUP BY day;
Use DynamoDB client and scan operation to run complex query.
Something like this not tested :
$client->scan([
'TableName' => 'omg',
'ScanFilter' => [
'id' => [
'AttributeValueList' => [
'S' => '0',
],
'ComparisonOperator' => 'NE',
],
'date' => [
'AttributeValueList' => [
'S' => date('Y-m-d', strtotime('-31 days')),
],
'ComparisonOperator' => 'GE',
],
],
'ConditionalOperator' => 'AND'
]);
ComparisonOperator
values list.
Keep in mind that this query will return only up to 1mb of data, you have to re-loop it. And don't even think about pagination :D
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.