title: SQL count based on timediff and column containing a string
body: <p>I'm using SQL Workbench.</p>
  
  <pre><code>cust_num    date    notes
  1234    2016-02-01  advice
  1234       2016-02-01   something else
  1234    2016-02-02  order
  1234    2016-02-03  order
  4421    2016-02-15  advice
  4421    2016-02-17  order
  4421    2016-02-18  something else
  4421    2016-02-24  order
  </code></pre>
  
  <p>I know the above is a bit unclear, but basically, there's 3 columns in the above table. One showing customer_num (customer number), one showing date and one showing a notes field.
  From the above, I want to perform two queries. I am newish to this so, I hope this is clear. I'm using SQL workbench.</p>
  
  <p>i) I want to count the number of DISTINCT 'customer_num's that placed an order within 4 days of receiving advice.</p>
  
  <p>So the answer based on the table above would be 3. This is because cust_num '1234' made two orders within 4 days and cust_num '4421' made 1 order. So that totals 3</p>
  
  <p>ii)I want to count the number of DISTINCT customer_num's that placed an order within 15 days of receiving advice. Only stipulation is that I don't want to re-count those from (i) that placed an order within 4 days. I want to exclude them.</p>
  
  <p>So the answer to this would be 1. Customer_num '4421' placed 1 order that was bigger than 4 days but smaller than or including 15 days.</p>
  
  <p>Any help really appreciated. Thank you.</p>