Jump to content

Double results after join


kmorrissey89

Recommended Posts

Hello,

 

Sorry but I'm sure this is an easy question but I am pretty new to SQL and trying to learn this on my own. I recently tried doing a query and got the results I was looking for but when I went to join a third table to get some more information in there all of the results doubled. Here is the code that I have, before I joined the team table to get the teamname in there everything worked fine.

 

 

Select p.commonname + ' ' + p.lastname as battername, teamname, count(defenseshift) as Shift

from players as p

left join results as r on r.batterid = p.playerid

left join team as t on t.teamid = r.batteamid

where r.defenseshift = 7

group by p.commonname, p. lastname, t.teamname

order by shift desc

 

Like I said I'm sure this is a 101 kind of problem, but any help in describing my mistake would be appreciated.

 

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...