How to group by data from rows to columns
我有一个下面的表格(时间表)。.我想将表格展平为Flattened_TimeSheet ..我可以在这里使用group by吗?如果没有,有人可以帮助我进行查询。
尝试:
1 2 3 4 5 6 7 | select ID, sum(case when type='a' then hour else 0 end) as A, sum(case when type='b' then hour else 0 end) as B, sum(case when type='c' then hour else 0 end) as C from TimeSheet where type in ('a', 'b', 'c') group by ID |