2017-11-11 41 views
-2

我有一個不同匹配記錄的MySQL表格。現在我想讓結果顯示我們的願望團隊與我們的願望團隊玩過的不同團隊的總比賽勝利比賽和丟失的比賽 我已經在一張圖片中解釋了我的問題link如何通過提供一些數據從一個SQL表格做出報告

+3

這是一個非常不確定的問題。你有哪些麻煩? – Protium

+1

歡迎來到SO.This不是網站,它將問題描述轉換爲代碼/查詢。展示你的嘗試,並告訴我們你失敗的地方。 –

+1

如果你明白我試圖問的問題比你可以做出這樣的查詢 –

回答

0

嘗試一次...

select tmat.t1 as 'Team',sum(`total Match`) as `total Match`, 
(select count(*) `total win` from tmatch where tmatch.w = tmat.t1) as `Total Win`, 
(select count(*) `total loss` from tmatch where tmatch.l = tmat.t1) as `Total loss` 

from (
SELECT t1,count(*) `total Match` from tmatch group by t1 
union all 
SELECT t2 ,count(*) `total Match` from tmatch group by t2) tmat group by tmat.t1 
相關問題