join – Sql multiple row based select like GraphQL
I have a large table i want to select different columns based on multiple conditions, rather than the entire column even if the row doesn’t need it.
something like :
i want (H1,H2) if HR1=R1 and (H2,H3) if H1=R2 …
problem is i can do a complete select to select all columns needed but that’s too much uneeded columns
tried
select from ((select H2,H3 where H1=R1),(select H2,H4 where H1=R2), (select H5 where H1=R3))
after a certain number of the conditions in the query i get an empty result.
| H1 | H2 | H3 | H4 | H5 |
|----|----|-----|-----|-----|
| R1 |[V1]|[V2] | V3 | V4 |
| R2 |[V5]| V6 |[V7] | V8 |
| R3 | V9 | V10 | V11 |[V12]|