I have 3 tables that look something like this:
Table1 Users:
- ID
- Name
- Score
Table2 Game:
- ID
- Name
- Fouls
Table 3 Game2
- ID
- Name
- Fouls
What I would like to do is to in Table1, select all users.
Then select all data where Table1.Name = Table2.Name OR Table1.Name = Table3.Name but with higher priority to Table2, so if there is a match Table1.Name = Table2.Name no join from Table 3 will be made. Then when I’ve selected the correct that I also would like to count the totalt sum of Score and Fouls.
How is this done in SQL and is it possible? I am using MSSQL
1 Answer