title: Select multiple values from different rows on table_a into one new row on table_b
body: <p>I have a table like below:</p>
  
  <pre><code>'table_a'
  Type | Value
  -----+------------
  000  | 100020003
  001  | 004
  002  | 5000600070008
  </code></pre>
  
  <p>I need to end up with a result set that is like below:</p>
  
  <pre><code>'table_b' 
   ---+---+---+---
   1 | 2 | 3 | 4     ETC...
  </code></pre>
  
  <p>I have used substring to pull 1, 2, and 3 where type = 000.  Now I need to do the same with type 001 and 002 but how can they be joined together to create one row in 'table_b'?</p>
  
  <p>So far I have used the below to populate 1, 2 and 3 but I have no idea how to select the data from the remaining rows.</p>
  
  <pre><code>SELECT SUBSTRING(Value,1,1) AS val_1
         SUBSTRING(Value,5,1) AS val_2
         SUBSTRING(Value,9,1) AS val_3
    FROM table_a
   WHERE type = 000
  </code></pre>
  
  <p>Next query would be like this:
       SELECT SUBSTRING(Value,3,1) AS val_4
         FROM table_a
        WHERE type = 001</p>
  
  <p>So as you can see I cannot use a union because I am not selecting the same number of items in each select statement.  </p>
  
  <p>The data I am pulling from is not this uniform but hopefully this conveys what I need to do correctly.  I greatly appreciate any assistance.</p>