Skip to content
Advertisement

How can I change the layout/structure of my table?

I currently have a table with 3 columns in it. The columns are best described as group_id, task and task_count. There are up to 15 possible tasks and over 500,000 group_ids. The task_count is the number of events that took place in a group_id for that task. Currently, the table looks like this:

So in group 5555 we only have 2 tasks: A which was done 45 times and N which was done 4 times. In 5624 we have 3 tasks with their respective counts. What I would like to do is put these values to where it displays based on the group id. So that it would look like:

              Pleae note that I’d like to incorporate the task value in the column name instead of ‘task_count’. What is the best way to convert it into the above format? Thank you.

Advertisement

Answer

You can use conditional aggregation:

Presumably, your original table is built from some unsummarized base table. You can apply this directly to that table:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement