Split one row to two

Hi, I have a summary table, one row looks like key1,count1,count2,count3,sum1,sum2,sum3. I want to display it like

key1,‘count’,count1,count2,count3
key1,‘sum’,sum1,sum2,sum3

How can I achieve this?

Has anyone any solutions?

First, the purpose of a key value is to ensure that you can’t have multiple rows with the same key. So what you are proposing outright, violates key constraints and wouldn’t be allowed.

What you could do is have a second table that you write to that adds a new row key value. Something like this:

Screen Shot 2020-03-24 at 8.11.24 PM

I do need to say that this is NOT very good data design and will likely cause issues later when you try to use and display this data.

Why is it that the initial summary table is in this format to begin with? e.g.
key1,count1,count2,count3,sum1,sum2,sum3

To prevent later frustration, maybe you can describe what you would like to have happen in the app? Then we can suggest a more appropriate data design.

2 Likes