There can be more elegant solutions but this one should work: SELECT DATE_FORMAT( Joined, '%m/%Y' ) AS MONTH , team, ( count( id ) / ( SELECT count( * ) FROM tablex WHERE DATE_FORMAT( Joined, '%m/%Y' ) = DATE_FORMAT( tx. Joined, '%m/%Y' ) GROUP BY DATE_FORMAT( Joined, '%m/%Y' ) ) *100 ) AS percentage FROM `tablex` AS tx GROUP BY DATE_FORMAT( Joined, '%m/%Y' ) , team.
1 Excellent answer! One minor issue though -- it doesn't include the 5/11 record for X that has 0 team members: sqlize. Com/164lD5bwbw – mellamokb Oct 12 at 14:14 But what if you have a team Z on 06/11, will you get a lot of records with 0's for X and Y?
If you want that, you're looking at a whole different solution. First retreive all possible teams, then query the db for all the months. Then for each month calculate the total members and percentage and add 0 for non-existing teams.
You could probably do it in one query but performance will be a disaster – Nin Oct 12 at 14:35 I agree with you. I'm just noting the discrepency between your solution and what the OP posted as the "required output". I would take that concern up with the OP.
– mellamokb Oct 12 at 14:51 Thanks Nin! It was very useful. In continuation to this I've posted other query please have a look at this link.
Link – munna 5/112 at 11:03.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.