Query SQL summing fields from one table with criteria from another

Asked

Viewed 64 times

2

I would like to do a query that adds for example the name of the equals by date (here I will put the period, for example 01/03 to 22/03), the problem that I have two tables, one of individuals where I have the name and one occurrences where I have the date, but I’m not succeeding in my attempts.
I tried something below, but it didn’t work out so well:

select COUNT(*), individuos.nome, ocorrencias.data_comunicacao  
from ocorrencias, individuos  
group by individuos.nome
  • There is a relationship between tables?

  • Has the id_occuren_ind in the table individuals which is foreign key of the table occurrences. Link 0.. N

  • 1

    @Marceloc.France approves the answer by marking if it is correct.

1 answer

2


Do the Where by listing the tables as below

select COUNT(*), individuos.nome, ocorrencias.data_comunicacao  
from ocorrencias, individuos  
where individuos .id_ocorrencia_ind  =ocorrencias.id_ocorrencia_ind 
group by individuos.nome

Browser other questions tagged

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