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

How to map id with name in presto

I have the below data in table1

id marks total
1 78 100
2 20 50

and I know 1 -> Sam and 2 -> Joe

I want to show

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

id percentage name
1 78 Sam
2 40 Joe

Not sure where to start when I have the id -> map as static map

>Solution :

If you have some kind of static data that is not a part of your dataset, you can hardcode it in the query by using WITH clause:

with static_map(id, name) as(
    values (1, 'Sam'),
    (2, 'Joe')
)

select t.id, t.marks, m.name
from table1 t
left join static_map m on t.id = m.id;
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