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
| 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;