title: SQL Query to get the value of a product given a date
body: <p>I have a table which gives the rate of a product on a particular date, #tableA.</p>
  <pre><code>create table #tableA
  (
      Id int not null,
      ValueDate date,
      Price decimal(9,2)
  )
  
  insert into #tableA (Id, ValueDate, Price)
  values 
      (1, '2020-08-01', 100),
      (1, '2020-08-05', 110),
      (1, '2020-08-07', 50)
  </code></pre>
  <p>My other table has the id and the date the product is active.</p>
  <pre><code>create table #tableB
  (
      Id int not null,
      Dates date
  )
  
  insert into #tableB (Id, Dates)
  values
      (1, '2020-08-01'),
      (1, '2020-08-02'),
      (1, '2020-08-03'),
      (1, '2020-08-04'),
      (1, '2020-08-05'),
      (1, '2020-08-06'),
      (1, '2020-08-07'),
      (1, '2020-08-04')
  </code></pre>
  <p>I cannot find an efficient query where my resulting table gives the rate of the product on a given date.</p>
  <p>I am expecting this result.</p>
  <pre><code>Id  Dates         ValueDate    Price 
  -------------------------------------
  1, '2020-08-01', '2020-08-01', 100
  1, '2020-08-02', '2020-08-01', 100
  1, '2020-08-03', '2020-08-01', 100
  1, '2020-08-04', '2020-08-01', 100
  1, '2020-08-05', '2020-08-05', 110
  1, '2020-08-06', '2020-08-05', 110
  1, '2020-08-07', '2020-08-07', 50
  </code></pre>