How to do a second query using the results of a previous query
Ok I need to count how many sales has made each of the sell agents of the
company, so I do This...
SELECT agentID, AgentName, COUNT(*) as total_sales FROM sales GROUP BY
agentID
This works perfectly, how ever It does not show the agents that had 0 sells.
So I need to perform a
SELECT agentID FROM agents
and the do a query of each result, so I can count how many sales had that
agent. I hope I explain it.
(I can do the loop in PHP, how ever Im wondering if is possible to do
directly in MySQL)
Regards
No comments:
Post a Comment