title: Select min and max with count
body: <p>I have a table called 'Medical Report'
  I need to select min date,max date in prescriptionwritten and corresponding active status for particular account number,code</p>
  <pre><code>Accountnumber code   prescriptionwritten.  Active      
  101            201          2019-10-21         0          
  101            201          2020-03-24         0     
  101            201          2020-05-25         1     
  101            202          2019-10-21         0     
  101            202          2020-06-20         1
  </code></pre>
  <p>Please help with sql query.</p>
  <p>The output:</p>
  <pre><code>101 201 2019-10-21 0  
  101 201 2020-05-25 1  
  101 202 2019-10-21 0  
  101 202 2020-06-20 1
  </code></pre>