title: Get latest record for each day for last n days using MS Sql Server
body: <pre><code>CurrencyId  LeftCurrencyId RightCurrencyId    ExchangeRateAt            ExchangeRate 
   1             1             5                2013-06-27 00:51:00.000    39.0123 
   2             3             5                2013-06-26 01:54:00.000    40.0120 
   3             1             5                2013-06-26 00:51:00.000    49.0143 
   4             3             5                2013-06-25 14:51:00.000    33.3123 
   5             3             5                2013-06-25 06:51:00.000    32.0163
   6             1             5                2013-06-25 00:08:00.000    37.0123  
  </code></pre>
  
  <p>I need latest record for each day for last n days based on combination of leftcurrencyid and rightcurrencyid. </p>