David Jones wrote:
>
> I'm using mySQL 3.22.14-gamma
>
> I have a table that contains task for people to do. I want a query that shows how
>many task each user assigned to them along with their percentage of the total tasks.
>Something kind of like this:
>
> user1 4 40%
> user2 3 30%
> user3 2 20%
> user4 1 10%
>
> I'm sure this can be done but I'm fairly new to the SQL stuff, so I could use some
>help!
Hi David
You have to do this with 2 SELECT statements.
1) get the total count of tasks:
SELECT count(*) FROM task
2) get what you really want:
SELECT userName, count(*) as absolut_count, count(*)/<result from above query> FROM
task GROUP BY userName
Tschau
Christian
-----------------------------------------------------------
Send a mail to [EMAIL PROTECTED] with
unsubscribe mysql [EMAIL PROTECTED]
in the body of the message to unsubscribe from this list.