SELECT [個人番号],[名簿区分],[執行日],
MAX(CASE WHEN [異動事由コード] = '11' THEN [異動日] ELSE NULL END) AS [国外転出_異動日], 
MAX(CASE WHEN [異動事由コード] = '11' THEN [異動届出日] ELSE NULL END) AS [国外転出_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '12' THEN [異動日] ELSE NULL END) AS [県外転出_異動日], 
MAX(CASE WHEN [異動事由コード] = '12' THEN [異動届出日] ELSE NULL END) AS [県外転出_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '13' THEN [異動日] ELSE NULL END) AS [県内転出_異動日], 
MAX(CASE WHEN [異動事由コード] = '13' THEN [異動届出日] ELSE NULL END) AS [県内転出_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '14' THEN [異動日] ELSE NULL END) AS [転出取消_異動日], 
MAX(CASE WHEN [異動事由コード] = '14' THEN [異動届出日] ELSE NULL END) AS [転出取消_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '41' THEN [異動日] ELSE NULL END) AS [死亡_異動日], 
MAX(CASE WHEN [異動事由コード] = '41' THEN [異動届出日] ELSE NULL END) AS [死亡_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '42' THEN [異動日] ELSE NULL END) AS [国籍喪失_異動日], 
MAX(CASE WHEN [異動事由コード] = '42' THEN [異動届出日] ELSE NULL END) AS [国籍喪失_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '43' THEN [異動日] ELSE NULL END) AS [失踪宣告_異動日], 
MAX(CASE WHEN [異動事由コード] = '43' THEN [異動届出日] ELSE NULL END) AS [失踪宣告_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '51' THEN [異動日] ELSE NULL END) AS [職権消除_異動日], 
MAX(CASE WHEN [異動事由コード] = '51' THEN [異動届出日] ELSE NULL END) AS [職権消除_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '52' THEN [異動日] ELSE NULL END) AS [職権回復_異動日], 
MAX(CASE WHEN [異動事由コード] = '52' THEN [異動届出日] ELSE NULL END) AS [職権回復_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '21' AND [名簿区分] = '0' THEN [異動日] ELSE NULL END) AS [１１条_異動日], 
MAX(CASE WHEN [異動事由コード] = '21' AND [名簿区分] = '0' THEN [異動届出日] ELSE NULL END) AS [１１条_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '21' AND [名簿区分] = '9' THEN [異動日] ELSE NULL END) AS [４条_異動日], 
MAX(CASE WHEN [異動事由コード] = '21' AND [名簿区分] = '9' THEN [異動届出日] ELSE NULL END) AS [４条_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '31' THEN [異動日] ELSE NULL END) AS [誤載_異動日], 
MAX(CASE WHEN [異動事由コード] = '31' THEN [異動届出日] ELSE NULL END) AS [誤載_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '32' AND [名簿区分] = '0' THEN [異動日] ELSE NULL END) AS [新住所地_異動日], 
MAX(CASE WHEN [異動事由コード] = '32' AND [名簿区分] = '0' THEN [異動届出日] ELSE NULL END) AS [新住所地_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '32' AND [名簿区分] = '9' THEN [異動日] ELSE NULL END) AS [他市登録_異動日], 
MAX(CASE WHEN [異動事由コード] = '32' AND [名簿区分] = '9' THEN [異動届出日] ELSE NULL END) AS [他市登録_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '33' THEN [異動日] ELSE NULL END) AS [４ヶ月抹消_異動日], 
MAX(CASE WHEN [異動事由コード] = '33' THEN [異動届出日] ELSE NULL END) AS [４ヶ月抹消_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '34' THEN [異動日] ELSE NULL END) AS [補正登録_異動日], 
MAX(CASE WHEN [異動事由コード] = '34' THEN [異動届出日] ELSE NULL END) AS [補正登録_異動届出日], 
MAX(CASE WHEN [異動事由コード] = '61' THEN [異動日] ELSE NULL END) AS [在外移転_異動日], 
MAX(CASE WHEN [異動事由コード] = '61' THEN [異動届出日] ELSE NULL END) AS [在外移転_異動届出日] 
FROM [選挙人異動情報]
GROUP BY [個人番号],[名簿区分],[執行日]