Created
April 24, 2024 05:19
-
-
Save agaase/3f50592561df614874165e34238bcb07 to your computer and use it in GitHub Desktop.
query-revenue-total
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
$match: { | |
status: {$ne: "cancelled"}, | |
createdAt: {$gt: ISODate('2024-03-31')} | |
} | |
}, | |
{ | |
$group: { | |
_id: { day: { $dayOfMonth: "$createdAt"}, year: { $year: "$createdAt" } }, | |
totalAmount: {$sum: "$revisedOrderTotal"} | |
}, | |
}, | |
{ | |
$sort: { | |
"_id.day": 1 | |
} | |
}, | |
{ | |
$project: { | |
"_id": 0, | |
"date": "$_id.day", | |
"year": "$_id.year", | |
"totalAmount": 1 | |
} | |
}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment