title: Nested group by with conditional query
body: <p>I have 3 tables:</p>
  <p><strong>table: a</strong></p>
  <pre><code>id  name
  2   A
  3   B
  </code></pre>
  <p><strong>table: b</strong></p>
  <pre><code>id  a        b                
  3   2        Asd Ter Gsdt      
  4   2        Gsd Gsdt Gsda
  5   2        Asd Gsd
  6   3        Uty Kggs
  7   3        Tyud Hffddf
  </code></pre>
  <p><strong>table: c</strong></p>
  <pre><code>id  a           b
  6   3           d       
  7   3           a      
  8   3           g
  9   3           h
  10  4           j
  11  5           y
  12  5           s
  13  6           d
  14  6           h
  </code></pre>
  <p><strong>expected output:</strong></p>
  <pre><code>a     b                 c           d
  A     2019-04-06        3           a
  B     2019-04-06        6           b
  </code></pre>
  <p>I am unsure how to proceed from this, how?</p>