0
我正在嘗試生成池匹配的結果。我在計算一名球員在比賽中贏得的幀數,但是對於那些沒有贏得比賽的球員而言,難以產生結果。如何生成不符合計數條件的記錄與
我讀過,當使用計數和組通過記錄返回0被刪除,但我不確定任何其他方法,我可以使用。
請你可以告訴我怎麼可以在下面改善我的查詢,謝謝:)
select
t1.Match_ID,
t1.Home_Player_ID,
Frames_Won,
coalesce(Frames_Lost,0) as Frames_Lost
from
(
select
Match_ID,
Home_Player_ID,
count(*) as Frames_Won
from
Match
where
Home_Player_Win = 1
and
Match_ID = '56D4FF05-5F33-43FC-A566-2251E790C57F'
group by
Match_ID,
Home_Player_ID
) t1
left join
(
select
Match_ID,
Home_Player_ID,
count(*) as Frames_Lost
from
Match
where
Home_Player_Win = 0
and
Match_ID = '56D4FF05-5F33-43FC-A566-2251E790C57F'
group by
Match_ID,
Home_Player_ID
) t2
on t1.Home_Player_ID = t2.Home_Player_ID
總和,當然!返回的結果集正是我所追求的。謝謝。 – Floyd