Doubt in select with group by and count?

1

I'm doing SQL in 2 tables in Oracle and would like to group the information according to the job code and also count how many people are in that charge.

I'm using the following SQL :

select f.numemp, f.numcad, f.nomfun, f.codcar, c.titcar, count(*) from R034fun f
join R024car c
on f.codcar = c.codcar
where f.codcar in ('0001157','800739','800852') and f.sitafa <> 7 
group by f.codcar

But I get the following error:

  

ORA-00979: não é uma expressão GROUP BY 00979. 00000 - "not a GROUP BY expression" Cause:Action: Erro na linha: 1 Coluna: 8

Can anyone help me by saying what's wrong with my code?

    
asked by anonymous 03.05.2017 / 20:55

1 answer

2

In Oracle the "group by" must be the same as the "select"

select f.numemp, f.numcad, f.nomfun, f.codcar, c.titcar, count(*) from R034fun f
join R024car c
on f.codcar = c.codcar
where f.codcar in ('0001157','800739','800852') and f.sitafa <> 7 
group by f.numemp, f.numcad, f.nomfun, f.codcar, c.titcar
    
03.05.2017 / 21:02