MySQL : Multiple counts in one query
I have a table of products. Every product has a company and a worker of
that company that produces it.
Something like this:
product | company | worker
--------------------------
1 2 John
2 2 Mike
3 2 Jim
4 3 Mark
5 3 Fred
6 2 John
etc...
Is it possible to run one query by company, and count all products by
specific worker that works for selected company.
For example:
SELECT (count how many products each employed worker made) WHERE company = 2;
RESULT :
John:2
Mike:1
Jim:1
No comments:
Post a Comment