Improve query
am 16.09.2010 17:01:17 von Tompkins Neil--00c09f8a4e58e03ac8049061b7b0
Content-Type: text/plain; charset=ISO-8859-1
Hi,
Regarding my query below, is there anyway in which this query can be
improved ?
SELECT t1.players_brought, t2.players_sold, t3.team_balance,
t4.home_team_wages, t5.away_team_wages,
(t3.team_balance+t2.players_sold)-(t1.players_brought+t4.hom e_team_wages+t5.away_team_wages)
AS team_balance,
t6.home_prize_money, t7.away_prize_money
FROM(SELECT SUM(bid_value) players_brought
FROM players_bids
WHERE teams_id_from = 1
AND bid_status = 'approved'
AND worlds_id = 1 ) AS t1,
(SELECT SUM(bid_value) players_sold
FROM players_bids
WHERE teams_id_to = 1
AND bid_status = 'approved'
AND worlds_id = 1 ) AS t2,
(SELECT SUM(amount) AS team_balance
FROM teams_finance
WHERE teams_id = 1) AS t3,
(SELECT
SUM(home_team_wages) AS home_team_wages
FROM fixtures_results
WHERE home_teams_id = 1
AND status = 'approved') AS t4,
(SELECT
SUM(away_team_wages) AS away_team_wages
FROM fixtures_results
WHERE away_teams_id = 1
AND status = 'approved') AS t5,
(SELECT
SUM(prize_money) AS home_prize_money
FROM fixtures_results
WHERE home_teams_id = 1
AND status = 'approved') AS t6,
(SELECT
SUM(prize_money) AS away_prize_money
FROM fixtures_results
WHERE away_teams_id = 1
AND status = 'approved') AS t7
Cheers
Neil
--00c09f8a4e58e03ac8049061b7b0--