I am more used to using SQL. I watched many mongodb videos in the hope to find a solution to something that is very easy to do in SQL. I thought it should be simple in MongoDb but it does not appear to be. For example I have three documents:
I want to get the count of distinct SessionID and also the count of the documents.
In SQL we do this very easy using a count of distinct:
// SELECT Count(DISTINCT SessionID), count(*) FROM reports_stats...
// Result is:
count(distinct sessionid) --> 2
allCount(*) --> 3
I cannot figure out how to do this in MongoDb! Simple grouping is easy in Mongo. But if I want to count the distinct SessionID and also count ALL of the docs and return it, like the above SQL result - Mongo is not easy to do this!
Thanks for picking up my post! Are you familiar with Facet? I tried to read it before but I didn’t seem clear to me. Are you able to do an example using the my post? I’ll do some more searches, but it would be helpful f you could do a moch or an example with how I might go about htis using my own example data.