0

I have a table as below (Time sheet)..I want to flatten the table to Flattened_TimeSheet..Can I use group by here? If not could someone help me with the query.

enter image description here

Relativity
  • 6,690
  • 22
  • 78
  • 128

1 Answers1

1

try this:

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
Esperento57
  • 16,521
  • 3
  • 39
  • 45