title: Firebase count group by
body: <p>Does Firebase supports grouped counting?<br>
  I would like to get counting for specific key grouped by the value.  </p>
  
  <p>Example of my data structure:  </p>
  
  <pre><code>"playbackPosition" : {
      "-JZ2c7v-imQXaEx2c4Cs" : {
          "data" : "0"
      },
      "-JZ2cDta73UGAgwIOejL" : {
          "data" : "25"
      },
      "-JZ2cJutDZu-7quLpLI2" : {
          "data" : "50"
      },
      "-JZ2cO-Me0nGK5XLTwd-" : {
          "data" : "75"
      },
      "-JZ2cSh-XnstYxbE_Zad" : {
          "data" : "100"
      },
      "-JZ2cWxya0-kmTPCze4u" : {
          "data" : "0"
      },
      "-JZ2c_wX-ODv43TKXkNG" : {
          "data" : "25"
      }
  }
  </code></pre>
  
  <p>Required results based on the <code>data</code> key :  </p>
  
  <pre><code>0 =&gt; 2  
  25 =&gt; 2  
  50 =&gt; 1  
  75 =&gt; 1  
  100 =&gt; 1
  </code></pre>
  
  <p>And of course I must consider that it will have thousands of children's, not only 7...  </p>
  
  <p>Thanks ahead!</p>
  
  <p><strong>EDIT</strong><br>
  Deeper explanation of the app and the problem we want to solve.   </p>
  
  <p>We have video scripts which runs on different websites, each video session (a user session) sends events and data, you can see an example here, check the Network tab - <a href="https://secure.bwebi.co/videostir/regular.html" rel="noreferrer">https://secure.bwebi.co/videostir/regular.html</a>  </p>
  
  <p>Our goal is to collect this data and create an analytics real time dashboard with few charts and graphs.  </p>
  
  <p>You can see our current data structure <a href="https://secure.bwebi.co/videostir/vs-analytics-g-1-export.json" rel="noreferrer">here</a></p>
  
  <p>Example for graphs we need:<br>
  <em>Completion rate</em><br>
  General - Bar graph showing overall number of views per clip duration pre defined periods.<br>
  Filters - date (start/end), unique/all, All urls / specific urls (embed on), All configurations / specific configurations/ ignore silent.<br>
  X axis - groups 0-25, 25-50,50-75,75-99, 100<br>
  Y axis - number of views    </p>
  
  <p><em>Views per day (with completion rate)</em><br>
  General - Multi lines graph showing number of views per day per duration periods.<br>
  Filters - date (start/end), unique/all, All urls / specific urls (embed on), All configurations / specific configurations / ignore silent.<br>
  X axis - Time in days<br>
  Y axis - Number of views<br>
  Lines for:<br>
  Total daily views<br>
  Daily views with 100% duration<br>
  Daily views with 75-99% duration<br>
  Daily views with 50-75% duration<br>
  Daily views with 25-50% duration<br>
  Daily views with 0-25% duration    </p>
  
  <p>Hope it's more clear now!</p>