i have a work collection, with fields work_id, work_ref, sequence, etc. I need a query for mongodb for its sql server equivalent : select work_id, work_ref from work w1 where w1.sequence = (select max(sequence) from work w2 where w2.work_order_ref = w1.work_order_ref)
question from:https://stackoverflow.com/questions/65912600/mongo-db-query-for-passing-value-from-outer-query-into-inner-query