How To Get Max And Min Value In MongoDB

Praveen Singh         No comments

In the last post, we have seen how to use GROUP BY in Mongodb. Now, we can use this knowledge to get the MAX and MIN values from the dataset.

Ok, so first we will see  SQL's way...


This is a very basic query. We can also use many other options with this query.I will try to cover more in my next post.

So now, NoSql's way...


Nothing complicated, just created info collection and inserted some values into it.

We have all data with us...So, we can look for the min values now...



 We are grouping the values based on the Id's here.But what if I want to see only the min value in whole group..you can try this one:


Just replace $min with $max, and you can get the max value.

Published by Praveen Singh

A blogger by passion.You can find me tucked in my bed and blogging on weekends when not roaming around. Besides blogging, I love music and you can find my songs on my fb page:PraveenUnplugged
.
Follow on Youtube : Videos On Latest Happenings |ThingsToKnow
.
Follow us Talend In Action

0 responses:

© 2015 Techie's House. Designed by Bloggertheme9