title: Select distinct count cloudant/couchdb
body: <p>I am starting a project using Cloudant.
  It's a simple system for logging, so I can track the usage of my apps.</p>
  
  <p>My documents looks like this:</p>
  
  <p>{ <br>
  app:'name of the app',<br>
  type:'page view | login | etc..',<br>
   owner:'email_of_the_user',<br>
   device: 'iphone | android | etc..',<br> date:
   'yyyy-mm-dd'<br>
   }</p>
  
  <p>I've tried to do some map reducing and faceted searches, but couldn't find so far the result for what I want.</p>
  
  <p>I want to count the number of distinct documents grouped by same owner, date (yyyy-mm-dd), and app.</p>
  
  <p>[For example, if a the same guy logs in the app twice or 20 times in the same date, it will be counted only once.
  I want to count how many single users used an app each day, no matter what's the type of the log, or the device he used.]</p>
  
  <p>If it was SQL, assuming that each key of the document is a column, I would query something like this:</p>
  
  <p>SELECT app, date, count(*) FROM LOGS group by date, owner, app</p>
  
  <p>ant the result would be something like:</p>
  
  <p>'App1', '2015-06-01', 200<br>
  'App1', '2015-06-02', 232<br>
  'App2', '2015-06-01', 142<br>
  'App2', '2015-06-02', 120<br></p>
  
  <p>How can I get the same result using Cloudant/CouchDB?</p>