I’m trying to combine multiple column values into 1 and then label them distinctly with a new column for a rollup table. Please see below for example.
Example:
(select
id, size, size2
from
table1
where
date = curdate()
)a
union all
(select
id, size, size2
from
table2
where
date = curdate()
)b
output:
ID size size2
1 23 47
2 25 33
How would I combine size and size2 into one column, and have another field that labels them?
Output would look like this:
ID values type
1 23 size
2 47 size2
3 25 size
4 33 size2
I’m thinking this should be some type of case statement, but I can’t seem to wrap my mind around it. Any ideas?
You could write a 4 part union. New ids are interleaved from table1/2.ids: