title: MySQL Query for counting number of recurrence by latest date
body: <p>I have the following table:</p>
  
  <pre><code> client  datescanned  owa
   user1    2019-02-27   A1
   user1    2019-02-28   A3
   user1    2019-02-29   A6
   user1    2019-02-29   A2
   user1    2019-02-29   A1
  </code></pre>
  
  <p>This is my query</p>
  
  <pre><code> SELECT COUNT(*) FROM s1 WHERE OWA= "A1" AND CLIENT ='user1' and 'datescanned' = 
   ( SELECT max('datescanned') FROM s1)
  </code></pre>
  
  <p>Basically I just want to have the count of A1 only for the latest date (2019-02-29).  In this case, it should return 1, now it's returning 2 (picking up A1 from 2019-02-27.</p>
  
  <p>Any help would be greatly appreciated!!</p>
  
  <p>Thanks
  Nathalie</p>
  
  <p>** UPDATE 1 **</p>
  
  <p>Now the following working except...</p>
  
  <pre><code>SELECT COUNT(*) 
  FROM s1
  WHERE trim(OWA)= "A1" 
  AND trim(CLIENT) ='user1' 
  AND datescanned  =  ( SELECT max(datescanned) FROM s1 where trim(OWA) 
  ='A1')
  </code></pre>
  
  <p>Updated Table</p>
  
  <pre><code> client  datescanned  owa
   user1    2019-02-27   A1
   user1    2019-02-28   A3
   user1    2019-02-29   A1
   user1    2019-02-29   A1
   user1    2019-02-30   A0
   user1    2019-02-30   A3
  </code></pre>
  
  <p>If there is no A1 for the latest date 2019-02-30, it gives me "2" since there are two A1 in 2019-02-29...</p>
  
  <p>I want the value to be zero since there is no A1 for the latest date only.</p>