title: Postgresql: Passing result of a select query to jsonb_to_recordset is not working
body: <p>I have a table with the below format.</p>
  <p>TableName: data</p>
  <p><a href="https://i.stack.imgur.com/AnViK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AnViK.png" alt="data table" /></a></p>
  <p>I have the below query to extract the <code>data2</code> jsonb.</p>
  <pre><code>select comment-&gt;data2 from data where id=1
  </code></pre>
  <p>I have to fetch the resulting jsonb as recordset like</p>
  <p><a href="https://i.stack.imgur.com/GuGB7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GuGB7.png" alt="enter image description here" /></a></p>
  <p>I figured that <code>jsonb_to_recordset</code> will help in yielding the result as expected but when I tried to run the below query</p>
  <pre><code>select * from json_to_recordset(select comment-&gt;data2 from data where id=1) as x(valueId text, valueType text);
  </code></pre>
  <p>but i get the below error</p>
  <pre><code>Query 1 ERROR: ERROR:  syntax error at or near &quot;select&quot;
  LINE 1: select * from json_to_recordset(select comment-&gt;data2...
  </code></pre>
  <p>Can someone guide on what I'm doing wrong here?</p>