如何在一行中显示一对多的 "The Many"

How to display "The Many" of a One-to-Many on One Line

我获得了 2 个文件,作为两个表格:'VoterData' 和 'VoterHistory' - 什么是完成我预期显示的最佳方式?

预期展示

ID      | First Name | Last Name   | Election1 | Election2 | Election3
--------+------------+-------------+-----------+-----------+----------
2155077 | Camille    | Bocchicchio | 2016June7 | 2016Nov8  | 2018June5
2155079 | Manabu     | Lonny       | 2016June7 | 2016Nov8  | 
2155083 | Scott      | Bosomworth  | 2016June7 |           | 2018June5



一- 'VoterData'

lVoterUniqueID | szNameFirst | szNameLast
---------------+-------------+------------
2155077        | Camille     | Bocchicchio  
2155079        | Manabu      | Lonny  
2155083        | Scott       | Bosomworth  

许多- 'VoterHistory'

lVoterUniqueID | sElectionAbbr 
---------------+---------------
2155077        | 2016June7     
2155077        | 2016Nov8      
2155077        | 2018June5  
2155079        | 2016June7      
2155079        | 2016Nov8      
2155083        | 2016June7       
2155083        | 2018June5    

使用交叉表查询

TRANSFORM First(H.sElectionAbbr) AS FirstOfsElectionAbbr
SELECT H.lVoterUniqueID AS ID, D.szNameFirst AS [First Name], D.szNameLast AS [Last Name]
FROM VoterData AS D INNER JOIN VoterHistory AS H ON D.lVoterUniqueID = H.lVoterUniqueID
GROUP BY H.lVoterUniqueID, D.szNameFirst, D.szNameLast
PIVOT H.sElectionAbbr;