这是我的查询:
SELECT title1,
[precinct percent] AS [PrecinctPercent],
leader,
[leader percent] AS [LeaderPercent],
Winner,
WinningVotes,
leader2,
[leader2 percent] AS [Leader2Percent],
Loser,
LosingVotes
FROM [leader].dbo.[RACE] r inner join
(select rc.[race number],
max(case when seqnum = 1 then [candidate num] end) as Winner,
max(case when seqnum = 1 then Votes end) as WinningVotes,
max(case when seqnum = 2 then [candidate num] end) as Loser,
max(case when seqnum = 2 then Votes end) as LosingVotes
from (select rc.*,
row_number() over (partition by rc.[race number] …Run Code Online (Sandbox Code Playgroud)