title: how to get quarter, half year, yearly and 24 months reports in mysql?
body: <p>I am working on requirement of generating reports for every 1, 3, 6, 12, and 24 months respectively where user selects his choice by a select dropdown. First I wrote query to generate report for 1 month which was worked fine. But I am not sure how to make that selection dynamic based on user selection.</p>
  
  <p>My query is below:</p>
  
  <pre><code>switch($months){
      case "1":
          $stmt = $pdo-&gt;prepare("SELECT count(*) as totalrows FROM today_analysis WHERE order_status=:order_status AND MONTH(track_date)=MONTH(CURDATE())");
          break;
      case "3":
          $stmt = $pdo-&gt;prepare("SELECT count(*) as totalrows FROM today_analysis WHERE order_status=:order_status AND CEIL(MONTH(track_date) / 3)");
          break;
      case "6":
          $stmt = $pdo-&gt;prepare("SELECT count(*) as totalrows FROM today_analysis WHERE order_status=:order_status AND CEIL(MONTH(track_date) / 6)");
          break;
      case "12":
          $stmt = $pdo-&gt;prepare("SELECT count(*) as totalrows FROM today_analysis WHERE order_status=:order_status AND CEIL(MONTH(track_date) / 12)");
          break;
      case "24":
          $stmt = $pdo-&gt;prepare("SELECT count(*) as totalrows FROM today_analysis WHERE order_status=:order_status AND CEIL(MONTH(track_date) / 24)");
          break;
  }
  </code></pre>
  
  <p>My Select dropdown is:</p>
  
  <pre><code>&lt;select name="month_analysis" id="month_analysis" class="month_analysis"&gt;
              &lt;option value="1" &lt;?php echo (isset($_GET['monthly']) &amp;&amp; $_GET['monthly']=='1')?'selected':''?&gt;&gt;Current Month&lt;/option&gt;
              &lt;option value="3" &lt;?php echo (isset($_GET['monthly']) &amp;&amp; $_GET['monthly']=='3')?'selected':''?&gt; &gt;3 Months&lt;/option&gt;
              &lt;option value="6" &lt;?php echo (isset($_GET['monthly']) &amp;&amp; $_GET['monthly']=='6')?'selected':''?&gt; &gt;6 Months&lt;/option&gt;
              &lt;option value="12" &lt;?php echo (isset($_GET['monthly']) &amp;&amp; $_GET['monthly']=='12')?'selected':''?&gt; &gt;12 Months&lt;/option&gt;
              &lt;option value="24" &lt;?php echo (isset($_GET['monthly']) &amp;&amp; $_GET['monthly']=='24')?'selected':''?&gt; &gt;24 Months&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Presently, The query seems to be working but I am not sure if it is working fine or not. Please any suggestions/help? Thanks.</p>