mysql - Using a joinquery's results in a union query to calculate a new value -
i trying merge 2 queries can see results of 2 queries on 1 line.
the first query is
select userscore.week, userlist.user_id, userteam.user_teams, userscore.team_points, userplayers.team_players wp_table1 userlist join wp_table2 userteam on userlist.user_id = userteam.user_id join wp_table3 userscore on userteam.user_teams = userscore.user_teams join wp_table4 userplayers on userteam.user_teams = userplayers.user_teams , userscore.week = userplayers.week userlist.list_id = 2 , userlist.unsub_date = 0 , userscore.week = 22 , userplayers.week = 22
and way of example, 1 row returns
- week = 22
- user_id = 5
- user_teams = 8087
- team_points = 160.81
- team_players = 13,163,238,482,42,212,398,471,222,442,353
i have second query
select round(sum(ppp),2) gwpoints ( select sum(points) ppp wp_table5 season_id = 77 , (week between 22 , 26) , player_id in (13,163,238,482,42,212,398,471,222,442,353) group week union select points ppp wp_table5 season_id = 77 , (week between 22 , 25) , player_id in (13,163,238,482,42,212,398,471,222,442,353) group week order ppp desc ) dervpointstable
which returns gwpoints = 194.32
you can see above query contains results of first query, userplayers.team_players = 13,163,238,482,42,212,398,471,222,442,353
i merge these queries
- week = 22
- user_id = 5
- user_teams = 8087
- team_points = 160.81
- team_players = 13,163,238,482,42,212,398,471,222,442,353
- gwpoints = 194.32
but each time try mysql errors. can please?
Comments
Post a Comment