title: How to join two tables with max value not greater than another value of column
body: <p>Apologies for the confusing question title, but I'm not exactly sure how to describe the issue at hand.</p>
  
  <p>I have two tables in Oracle 9i:</p>
  
  <pre><code>Pricing
  -------
  SKU
  ApplicableTime
  CostPerUnit
  
  Inventory
  ---------
  SKU
  LastUpdatedTime
  NumberOfUnits
  </code></pre>
  
  <p><code>Pricing</code> contains incremental updates to the costs of each particular SKU item, at a specific Unix time. For example, if I have records:</p>
  
  <pre><code>SKU    ApplicableTime    CostPerUnit
  ------------------------------------
  12345  1000              1.00
  12345  1500              1.50
  </code></pre>
  
  <p>, then item 12345 is $1.00 per unit for any time between 1000 and 1500, and $1.50 for any time after 1500.</p>
  
  <p><code>Inventory</code> contains SKU, last updated time, and number of units.</p>
  
  <p>What I'm trying to do is construct a query such that for each row in <code>Inventory</code>, I join the two tables based on SKU, I find the largest value for <code>Pricing.ApplicableTime</code> that is NOT greater than <code>Inventory.LastUpdatedTime</code>, get the <code>CostPerUnit</code> of that particular record from <code>Pricing</code>, and calculate <code>TotalCost = CostPerUnit * NumberOfUnits</code>:</p>
  
  <pre><code>SKU    TotalCost
  -----------------------------------------------------------------------------------
  12345  (CostPerUnit at most recent ApplicableTime &lt;= LastUpdatedTime)*NumberOfUnits
  12346  &lt;same&gt;
  ...    ...
  </code></pre>
  
  <p>How would I do this?</p>