puyen
puyen

Reputation: 21

how to count how many person use the same id

I have this one table which is table staff. The column is id_staff, no_staff and id_posting. I would like to count how many staff using the same id_posting. Can anyone help me with the query?thanks.

Upvotes: 0

Views: 184

Answers (3)

dhi_m
dhi_m

Reputation: 1265

Please try this

SELECT id_posting ,COUNT( `id_staff` ) as cnt_staff
FROM table_staff
GROUP BY id_posting

Upvotes: 0

Roby Samuel
Roby Samuel

Reputation: 21

Do you have tried to make the query yourself? This is quite basic

select count(id_staff), id_posting from staff where id_posting = ? group by id_posting

Upvotes: 1

ameenulla0007
ameenulla0007

Reputation: 2683

select COUNT(*) AS ID_COUNT from YOUR_TABLE group by THE_ID_WHICH_IS_REPEATED

http://www.w3schools.com/sql/sql_func_count.asp check the tutorial for more info.

Upvotes: 0

Related Questions