title: Unnesting and inserting json data in seperate rows and columns in postgresql (10.3)
body: <p>I have the following data set: </p>
  
  <pre><code>{"date":{"year":2017,"month":7,"day":2},"data":{"param1":[10,20,30,440],"param2":[55,65,75,85],"param3":[43,55,71,72]}}
  </code></pre>
  
  <p>I retrieve the data from a table called rawData.</p>
  
  <p>Now I want to unnest the values inside the arrays and put them in 4 separate rows and columns inside another table (seperateData), so for this example it would look like:</p>
  
  <pre><code>year  | month | day | param1 | param2 | param3
  
  2017      7      2      10       55       43
  2017      7      2      20       65       55
  2017      7      2      30       75       71
  2017      7      2      440      85       72
  </code></pre>
  
  <p>I am guessing I have to use unnest and ordinality to achieve this, but am stuck at how I should proceed. The arrays param1, param2, param3 are always of the same length.</p>
  
  <p>I've already made a fiddle with the data:
  <a href="https://www.db-fiddle.com/f/jZhYLEvdSERzLCDyoAJz65/0" rel="nofollow noreferrer">https://www.db-fiddle.com/f/jZhYLEvdSERzLCDyoAJz65/0</a></p>