Below is the document schema for Customer. It has nested 'transaction'
{
"_id": {
"$oid": "65e797c4d4ed4faa9d4e8425"
},
"user_id": "Test1_R_1",
"email": "lkasdjkhsdkhxsaun+6zcYYU",
"full_name": "iusakhlknsa==",
"omnture_hash_key": "Test1_R_1",
"language": "EN",
"transaction": {
"RESPONSE_CODE": "000",
"SETTLEMENT_CODE": "3",
"GENDER_FLG": "1",
"TERM_CITY": "SIOUX FALLS",
"CUST_AGE": "44",
"TERM_ID": "CASHDISP_T1"
},
"transaction_date": {
"$date": "2023-04-26T09:53:17.000Z"
},
"status": "Exported",
"status_code": 2,
"created_date": {
"$date": "2024-03-05T00:48:29.716Z"
},
"last_modified_date": {
"$date": "2024-03-02T00:45:11.166Z"
}
}
Below are the conditions to filter the documents.
Select user_id, email, transaction.* from customer
Group By Email
Having (max(createdDate) = today and max(status_code) < 5)
And
(max(lastModifiedDate + 2) < tomorrow)
Order by createdDate desc, user_id
Where createdDate < 90
What would be the aggregation pipeline for the above query?
I have no idea what you mean by
created_date < 90, but nevertheless it seems as if it should go to the very top.