Doubt in select with group by and Count?

Asked

Viewed 1,642 times

1

I’m making a 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 position.

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 someone help me by telling me what’s wrong with my code?

1 answer

2

Oracle "group by" has to be the same as "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

Browser other questions tagged

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