Query for document with least value


(Ruthvik Sai) #1

Hi,
How can I write a query such that I get the document with the least value of a particular field?
For ex: I have a "marks" field. how do I get the document having the least value of marks

Now if I extend the same thing how can I get the doc which was first created (least value of date stamp)...

Thanks


#2

you can use aggregation