Q&A about the site for 3D printing enthusiasts
CREATE table #yourtable ([Guid] int, [Name] varchar(20), [Type] varchar(20), [Email] varchar(20)); INSERT INTO #yourtable ([Guid], [Name], [Type], [Email]) VALUES (1, 'Tenko', 'HQ', '[email protected]'), (1, 'Tenko', 'Branch', '[email protected]'), (2, 'Roberto', 'Other', '[email protected]'), (2, 'Roberto', 'Field', '[email protected]'), (3, 'Dave', 'HQ', '[email protected]'); select Guid, Name, max(case when type = 'HQ' then type when type = 'Branch' then type when type = 'Field' then type when type = 'Other' then type end) Type, max(case when type = 'HQ' then email when type = 'Branch' then email when type = 'Field' then email when type = 'Other' then email end) Email from #yourtable group by Guid, Name order by Guid asc, Name