Sum query

Asked

Viewed 121 times

-1

I’m having some kind of problem with this query, but what I want to happen is for all values like: Goals Scored, Assists Made,Key passes etc, to make sum for each Player ID making them appear only once.

SELECT s.[Statistics ID], s.[Player ID],  s.[Game ID],  s.[Season ID],  s.[Goals Scored], s.[Assists Made],  s.[Key Passes], s.[Successful Tackles],  s.[Successful Interceptions], s.[Goals Conceded], p.[Player Name], p.[Player ID]    
FROM Statistics$ s, Players$ p
WHERE s.[Player ID]=p.[Player ID]

This is what appears in the view:

inserir a descrição da imagem aqui

  • Miranda your question is a little confused. Try to explain better what you want.

1 answer

1

To add up uses the SUM(field) and to make the player be displayed only once use DISTINCT field or can group using GROUP BY field:

SELECT
  DITINCT p.[Player ID],
  SUM(s.[Goals Scored]) AS gols_jogador,
  SUM(s.[Assists Made]) as assists,
  SUM(s.[Key Passes]) as passes
FROM Players$ p
INNER JOIN Statistics$ s ON s.[Player ID]=p.[Player ID]

I hope for certain :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.