title: How to count from first date till date?
body: <p>I have a table like below in SQL server</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Date</th>
  <th>Store ID</th>
  <th>Sales Amount</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>01-01-2021</td>
  <td>1001</td>
  <td>1000$</td>
  </tr>
  <tr>
  <td>01-01-2021</td>
  <td>1002</td>
  <td>1000$</td>
  </tr>
  <tr>
  <td>01-01-2021</td>
  <td>1003</td>
  <td>0$</td>
  </tr>
  <tr>
  <td>02-01-2021</td>
  <td>1001</td>
  <td>1000$</td>
  </tr>
  <tr>
  <td>02-01-2021</td>
  <td>1002</td>
  <td>1000$</td>
  </tr>
  <tr>
  <td>02-01-2021</td>
  <td>1003</td>
  <td>1000$</td>
  </tr>
  <tr>
  <td>03-01-2021</td>
  <td>1001</td>
  <td>1000$</td>
  </tr>
  <tr>
  <td>03-01-2021</td>
  <td>1002</td>
  <td>1000$</td>
  </tr>
  <tr>
  <td>03-01-2021</td>
  <td>1003</td>
  <td>1000$</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>how to calculate count of previous days if Sales Amount &gt; 0, using TSQL? (same as below column)</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Date</th>
  <th>Store ID</th>
  <th>Sales Amount</th>
  <th>Active Days</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>01-01-2021</td>
  <td>1001</td>
  <td>1000$</td>
  <td>1</td>
  </tr>
  <tr>
  <td>01-01-2021</td>
  <td>1002</td>
  <td>1000$</td>
  <td>1</td>
  </tr>
  <tr>
  <td>01-01-2021</td>
  <td>1003</td>
  <td>0$</td>
  <td>0</td>
  </tr>
  <tr>
  <td>02-01-2021</td>
  <td>1001</td>
  <td>1000$</td>
  <td>2</td>
  </tr>
  <tr>
  <td>02-01-2021</td>
  <td>1002</td>
  <td>1000$</td>
  <td>2</td>
  </tr>
  <tr>
  <td>02-01-2021</td>
  <td>1003</td>
  <td>1000$</td>
  <td>1</td>
  </tr>
  <tr>
  <td>03-01-2021</td>
  <td>1001</td>
  <td>1000$</td>
  <td>3</td>
  </tr>
  <tr>
  <td>03-01-2021</td>
  <td>1002</td>
  <td>1000$</td>
  <td>3</td>
  </tr>
  <tr>
  <td>03-01-2021</td>
  <td>1003</td>
  <td>1000$</td>
  <td>2</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Thanks in advance.</p>