Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Possible to un-anonymize VALUES clause?

Let’s say I have the following as a starting point:

select * from (values (1,'a'),(2,'b'))

Is it possible to provide column names to the value columns up-stream, for example something like:

select
    col1 AS id,
    col2 AS letter
from (
    <anonymous values>
)

Or is it basically once you have an anonymous values clause you cannot name it.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use a table alias that also specifies column names:

select * 
from ( 
  values (1,'a'),(2,'b')
) as v(id, letter);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading