title: SQL: Minimal break to next game per team
body: <p>Hello this is kindy tricky and I am struggling pretty hard. This goes way over my normal SQL skills :-) Here is the problem I am facing.</p>
  
  <p>I have a gameplan. The basic structure looks like this:</p>
  
  <pre><code>ID     League     GameDay     GameTime    HomeTeam     AwayTeam
  1        1       16.09.2018    10:00         A            B
  2        1       16.09.2018    10:00         C            D
  3        1       16.09.2018    14:00         E            F
  4        1       16.09.2018    14:00         A            C
  5        1       16.09.2018    17:00         B            D
  6        1       16.09.2018    17:00         F            A
  7        1       17.09.2018    10:00         E            D
  8        1       17.09.2018    10:00         C            B
  ----&gt; This goes on till league 6
  </code></pre>
  
  <p>I need to query now the minimal break time per Team per Day (and also per league, but the team name is unique). So in the above example Team A´s minimal break time on the 16.09.2018 would be 3 hours (the game from 17:00 minus the game from 14:00). </p>
  
  <p>After a few tries I think I realized I cant do that in one query so I broke it down to one team. And created a few querys with the following result (I selected just the HomeTeam in a query, then the AwayTeam and unioned this two):</p>
  
  <pre><code>League      GameDay     GameTime       Team
    1        16.09.2018    10:00          A
    1        16.09.2018    14:00          A
    1        16.09.2018    17:00          A
    1        16.09.2018    10:00          A
    1        16.09.2018    10:00          B
    1        16.09.2018    17:00          B
    1        17.09.2018    10:00          B
  ---&gt; And so on with the other teams
  </code></pre>
  
  <p>I have the feeling I am near the desired result but the last step is missing -.- </p>