sql server - SQL Transpose sum of field into columns -
sql server - SQL Transpose sum of field into columns - of sql transpose questions using pivot , unpivot yet see 1 transpose single row columns. query: select '' status, '' "count", sum(created) "created", sum(forwarded) "forwarded", sum(replied) "replied" ( select case when a.to_wg_id null , a.created_date_time = (select min(b.created_date_time) ymtn.message b b.thread_id = a.thread_id) 1 else 0 end "created", case when a.to_wg_id not null , a.from_wg_id not null 1 else 0 end "forwarded", case when a.to_wg_id null , a.created_date_time != (select min(b.created_date_time) ymtn.message b b.thread_id = a.thread_id) 1 else 0 end "replied" ymtn.message left bring together ymtn.workgroup b on a.from_wg_id=b.workgroup_id b.workgroup_id='1stop_process' ) and