title: Dynamic Sql Pivot Two Columns of Table
body: <p>Using Dynamic Pivots Tables, I'm trying to get this table: <a href="http://www.sqlfiddle.com/#!18/9f1cf/47" rel="nofollow noreferrer">http://www.sqlfiddle.com/#!18/9f1cf/47</a></p>
  
  <p>To look something like this: (Some Columns removed for brevity, assume I can have one or more columns past "Chosen Council", this is the expected design only not the expected result)</p>
  
  <p>Note that Zip codes can be null, can share Councils, and can repeat over the days</p>
  
  <pre><code>+============+=======+================+============================+====================================+=========================+=====================+
  | Call Date  |  Zip  | Chosen Council | Early Childhood Group Care | Development / Developmental Delays | Caregiver Mental Health | Behavioral Concerns |
  +============+=======+================+============================+====================================+=========================+=====================+
  | 2018-05-01 | 85000 | Maricopa North | null                       | 1                                  | 2                       | null                |
  +------------+-------+----------------+----------------------------+------------------------------------+-------------------------+---------------------+
  | 2018-05-01 | 85001 | Maricopa North | 1                          | null                               | null                    | null                |
  +------------+-------+----------------+----------------------------+------------------------------------+-------------------------+---------------------+
  | 2018-05-01 | null  | null           | null                       | 2                                  | null                    | null                |
  +------------+-------+----------------+----------------------------+------------------------------------+-------------------------+---------------------+
  | 2018-05-02 | 85000 | Maricopa North | null                       | 1                                  | 1                       | 3                   |
  +------------+-------+----------------+----------------------------+------------------------------------+-------------------------+---------------------+
  | 2018-05-02 | 85003 | Phoenix South  | null                       | null                               | null                    | 2                   |
  +------------+-------+----------------+----------------------------+------------------------------------+-------------------------+---------------------+
  | 2018-05-02 | 85004 | Phoenix South  | 1                          | 2                                  | null                    | 2                   |
  +------------+-------+----------------+----------------------------+------------------------------------+-------------------------+---------------------+
  | 2018-05-02 | null  | null           | null                       | 1                                  | 1                       | null                |
  +------------+-------+----------------+----------------------------+------------------------------------+-------------------------+---------------------+
  </code></pre>
  
  <p>I've seen a number of questions regarding Pivot Tables, both hard coded and dynamic, and I'm still not grasping it.</p>
  
  <p>Here, I was able to get a Dynamic Pivot Table for just the Call Topic Names and their Counts: <a href="http://www.sqlfiddle.com/#!18/9f1cf/39" rel="nofollow noreferrer">http://www.sqlfiddle.com/#!18/9f1cf/39</a><br>
  But that is only a single row for everything, it also seems to be ignoring nulls.</p>
  
  <p>Here I tried to expand on the above, and while it seems to be spacing out better, I haven't figured out how to attach my Call Date, Zip, or Chosen Council columns: <a href="http://www.sqlfiddle.com/#!18/9f1cf/37" rel="nofollow noreferrer">http://www.sqlfiddle.com/#!18/9f1cf/37</a></p>
  
  <p>Any ideas how I can do this?</p>
  
  <hr/>
  
  <p><em>ASCII Table made with: Made with <a href="https://ozh.github.io/ascii-tables/" rel="nofollow noreferrer">https://ozh.github.io/ascii-tables/</a></em></p>