How to perform the following select query?

with x (x, y, z) as
((2 5 6), (6,3,2))
select * from x

I am not sure if this approach is possible. Not even sure if the syntax is correct. But I don't want to make a table in my database. Actually I am writing a PL/pgSQL function where I have few numeric values like 2,5,6,3 etc in few variables and I want to create a table from those variables so that I can perform some SQL operations on them.

closed as off-topic by Paul White, ypercubeᵀᴹ, Mark Storey-Smith, RolandoMySQLDBA, Shawn Melton Oct 31 '14 at 20:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Paul White, ypercubeᵀᴹ, Mark Storey-Smith, RolandoMySQLDBA, Shawn Melton
If this question can be reworded to fit the rules in the help center, please edit the question.


The syntax is almost correct. You need the keyword values and some commas that are missing:

with x (x, y, z) as 
    (2, 5, 6), 
    (6, 3, 2)
select * 
from x;
  • that was greatttt !! :) – Zia Oct 30 '14 at 20:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.