I just started learning SQL the other day and hit a stumbling block. I've got some code that looks like this:
SELECT player, SUM(wins) from (
SELECT win_counts.player, win_counts.wins
from win_counts
UNION
SELECT lose_counts.player, lose_counts.loses
from lose_counts
group by win_counts.player
) as temp_alias
Here is the error I get:
ERROR: missing FROM-clause entry for table "win_counts" LINE 7: group by win_counts.player
This win_counts table contains a list of player ids and the number of matches they have one. The lose_counts tables contains a list of player ids and the number of matches they have lost. Ultimately I want a table of player ids and the total number of matches each player has played.
Thank you for the help. Sorry I don't have more information... my understanding of sql is pretty rudimentary.
UNIONis definitely wrong for this query It should beUNION ALL.