Diego Donoso
Diego Donoso

Reputation: 69

How to get the amount of jobbers per area?

I'm trying to get the amount of jobbers (employees) per area (work) but i don't know how to do it. I tried doing this

select NOMBRE_ORDEN_TRABAJO,
    id_usuario as Jobber_count
from tareas 
group by NOMBRE_ORDEN_TRABAJO;

I get this

enter image description here

I think i should use the sentence COUNT.

This is my bd (in excel) where you can see i have an user id (ID USUARIO) and nombre orden trabajo (aerea/work name)... I'd like to count every jobber/employer per aera/work..

enter image description here

Upvotes: 0

Views: 24

Answers (1)

Matt Drake
Matt Drake

Reputation: 156

You do need a COUNT in there.

Try...

select NOMBRE_ORDEN_TRABAJO,
    COUNT(id_usuario) as Jobber_count
from tareas 
group by NOMBRE_ORDEN_TRABAJO;

This will give you the number of id_usuario per NOMBRE_ORDEN_TRABAJO

If you are concerned there may be duplicates change to COUNT(DISTINCT id_usuario)

Upvotes: 1

Related Questions