title: Count devices per day in a given date range
body: <p>I have a table which has devices with 3 statuses, Pass, Fail and Warning.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">Device</th>
  <th style="text-align: center;">Status</th>
  <th style="text-align: center;">Date</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">Device1</td>
  <td style="text-align: center;">Pass</td>
  <td style="text-align: center;">12/1/2020</td>
  </tr>
  <tr>
  <td style="text-align: center;">Device2</td>
  <td style="text-align: center;">Fail</td>
  <td style="text-align: center;">12/1/2020</td>
  </tr>
  <tr>
  <td style="text-align: center;">Device3</td>
  <td style="text-align: center;">Warning</td>
  <td style="text-align: center;">12/1/2020</td>
  </tr>
  <tr>
  <td style="text-align: center;">Device1</td>
  <td style="text-align: center;">Fail</td>
  <td style="text-align: center;">12/2/2020</td>
  </tr>
  <tr>
  <td style="text-align: center;">Device2</td>
  <td style="text-align: center;">Warning</td>
  <td style="text-align: center;">12/2/2020</td>
  </tr>
  <tr>
  <td style="text-align: center;">Device3</td>
  <td style="text-align: center;">Pass</td>
  <td style="text-align: center;">12/2/2020</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I want to generate a trend graph of count of devices based on the daily status. The count is on all the devices for each day. The table above will have device data repeated for multiple dates.</p>
  <p>Example:
  I want to generate a stacked bar graph, which will show count of devices which are pass, fail or warning. Need to get a query which I can use to get the response back with <code>DateTime</code>, count of failed devices, count of devices passed, count of devices having warning over a range of dates.</p>
  <pre><code>select * (select count(*) from status_table where overall_status = 'Fail' and startDate &gt; &quot;&quot; and endDate &lt; &quot;&quot;) as failedCount,
  (select count(*) from status_table  where overall_status = 'Warning' and startDate &gt; &quot;&quot; and endDate &lt; &quot;&quot;) as WarningCount,
  (select count(*) from status_table  where overall_status = 'Pass'  startDate &gt; &quot;&quot; and endDate &lt; &quot;&quot;) as passCount from status_table
  </code></pre>
  <p>Is there a better solution?</p>