title: How to calculate percentage from two tables?
body: <p>please, help me calculate percentage of number of clients from two tables, which made payments during 01.01.2018 - 05.01.2018.</p>
  
  <pre><code>clients
  
  client_id  sum     date
  100      2400   01.01.2018
  101      2550   02.01.2018
  120      2345   05.01.2018
  155      5526   30.03.2018
  </code></pre>
  
  <p>the second table</p>
  
  <pre><code>payments 
  
  client_id   total  date
  100        47    01.01.2018
  101        50    02.01.2018
  120        0    05.01.2018
  155        20    30.03.2018
  </code></pre>
  
  <p>I write such query, but it does not work correctly:</p>
  
  <pre><code>SELECT (COUNT(distinct payments.client_id) / (COUNT(distinct 
  clients.client_id)) * 100) AS percent, payments.date 
  FROM payments, clients WHERE
  payments.date between '2018-01-01' 
  and '2018-01-05' 
  GROUP BY
  (payments.date);
  </code></pre>
  
  <p>Thanks!</p>