-1
嘿,我該如何將以下兩個查詢合併爲一個?所以我得到的結果集爲一個,因爲第一個查詢是從一個表獲得點結果,下表從另一個表中獲得我需要的剩餘部分,但這兩者都與彼此相關,因爲第一個查詢被執行時可以用它來做secound查詢。我只是不知道如何?任何幫助都很好。結合兩個查詢的MYSQL QUERY
SELECT t.team_id, t.teamname, t.code, t.value,
SUM(Case When track_id = (SELECT MAX(track_id) FROM team_stats) Then points Else 0 End) lastracepoints,
SUM(points) AS points
FROM team_stats ts
Left Join teams t
on t.team_id = ts.team_id
GROUP BY ts.team_id
SELECT SUM(IF(qual_pos = '1', 1,0)) AS poles,
SUM(IF(race_pos <= '3', 1,0)) AS podiums,
SUM(IF(race_pos = '1', 1,0)) AS victories,
SUM(overtakes) AS overtakes
FROM driver_stats s
left join drivers d
on d.drivers_id = s.drivers_id
GROUP by d.team_id
編輯您的問題以顯示您希望結果集的形狀。即垂直還是水平? –