title: SQL query to select rows from two table with some matching filters
body: <p>I have two tables. Data in my table like below.</p>
  
  <p>I need SQL query which display my expected output from above two tables.</p>
  
  <p><strong>holidayMaster</strong></p>
  
  <pre><code> id     Date
   1     12-04-2015
  </code></pre>
  
  <p><strong>Customer table</strong></p>
  
  <pre><code>Name    startingdate     coupondate
  A       12-03-2015      11-04-2015
  A       12-03-2015      11-05-2015
  A       12-03-2015      11-06-2015
  A       12-03-2015      11-07-2015
  A       12-03-2015      11-08-2015
  A       12-03-2015      11-09-2015
  
  B       13-03-2015      12-04-2015
  B       13-03-2015      12-05-2015
  B       13-03-2015      12-06-2015
  B       13-03-2015      12-07-2015
  B       13-03-2015      12-08-2015
  B       13-03-2015      12-09-2015
  
  C       14-03-2015      13-04-2015
  C       14-03-2015      13-05-2015
  C       14-03-2015      13-06-2015
  C       14-03-2015      13-07-2015
  C       14-03-2015      13-08-2015
  C       14-03-2015      13-09-2015
  </code></pre>
  
  <p><strong>FOR EX</strong> - In above customer table..there are 18 distinct rows ok, because coupondate are different in all rows.</p>
  
  <p>Suppose user select coupondate from 01-04-2015 to 31-04-2015 ,so query display name,startingdate, coupondate, and all days between selected filter 
  from 01-04 to 31-04.</p>
  
  <p>And display name, startingdate, coupondate and 1 below all days with total.</p>
  
  <p>And condition is if some days between selected days are available in holiday master then display - - - - -  to all days not 1.</p>
  
  <p>In below output <strong>12-04-2015 is available in holiday master ...so this display  - - - -  below all days..</strong></p>
  
  <p><strong>Expected Output</strong></p>
  
  <pre><code>name   startingdate  coupondate  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  Total
  
  A      12-03-2015     11-04-2015 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1      31
  B      13-03-2015     12-04-2015 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  C      13-03-2015     13-04-2015 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1      31
  </code></pre>