title: SQL joining same columns in different ways
body: <pre><code>select top 1000 
      f.*, s.TimeZoneCode as TimeZoneOrigin, 
      s2.TimeZoneCode as TimeZoneDestination,
      tz.StandardVariation as VariationOrigin, 
      tz2.StandardVariation as VariationDestination, 
      tzv.Variation as TimeVariation, 
      tzv2.Variation as TimeVariation2
  from 
      REZNVWB01.MIT.HVResearchDataSetDraft1 f
  inner join 
      REZNVOD01.dbo.Station s on s.StationCode = f.TripOriginLocationCode 
  inner join 
      REZNVOD01.dbo.Station s2 on s2.StationCode = f.TripDestinationLocationCode 
  inner join 
      REZNVOD01.dbo.TimeZone tz on tz.TimeZoneCode = s.TimeZoneCode
  inner join 
      REZNVOD01.dbo.TimeZone tz2 on tz2.TimeZoneCode = s.TimeZoneCode
  inner join 
      REZNVOD01.dbo.TimeZoneVariation tzv on tzv.TimeZoneCode = s.TimeZoneCode 
                                          and tzv.EndUTC &gt;= BookingDate
                                          and tzv.StartUTC &lt;= BookingDate
  </code></pre>
  
  <p>I have one table with <code>StartUTC</code> and <code>EndUTC</code> and <code>timezonevariation</code> for each row. I want to look at <code>BookingTime</code>, and gain the <code>timezonevariation</code> for when <code>bookingtime</code> is between <code>StartUTC</code> and <code>EndUTC</code>.</p>
  
  <p>What do I need to change in this code?</p>
  
  <pre><code> inner join 
       REZNVOD01.dbo.TimeZoneVariation tzv on tzv.TimeZoneCode = s.TimeZoneCode 
                                           and tzv.EndUTC &gt;= BookingDate
                                           and tzv.StartUTC &lt;= BookingDate
  </code></pre>
  
  <p>Is this code correct if the TimeZoneVariation code StartUTC and EndUTC are between conditions (IE startUTC might be 5:00 and endUTC might be 10:00, I want the TimeZoneVariation value where BookingDate is between startUTC and endUTC)</p>