[英]how to write this complex mysql query in Dynamo db
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.. 我如何才能将此查询修改为dynamo db查询,我无法找到有关聚合函数的示例以及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. 使用DynamoDB客户端和扫描操作来运行复杂的查询。
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. ComparisonOperator
值列表。
Keep in mind that this query will return only up to 1mb of data, you have to re-loop it. 请记住,此查询仅返回最多1mb的数据,您必须重新循环它。 And don't even think about pagination :D 而且甚至不用考虑分页:D
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.