Quantcast
Channel: General developer forum
Viewing all articles
Browse latest Browse all 37670

sql query group by name and average

$
0
0
by Mike Glazebrook.  

I am new to sql and am having a hard time figuring out what to query in order to get a google pie chart functioning correctly.

SELECT `rank`, `firstname`, `email`,`username`
FROM `mdl_user`, `mdl_questionnaire_response_rank`
WHERE 1
GROUP BY `email`

That is how I am running the query right now. I have attached a screen shot of how it displays right now.

It is exactly how I want it other than when I grouped it by `email` it forced all the ranks to be the same number.

I want to group it the way that it is but then show the AVG rank per user in the users section of the pie chart.

so Alex may have a 45% section of chart while Mike may have 75%.

If I get that much I will be happy but I will also eventually want to make the chart so that only the user will be able to see their average slice of the pie chart to an average of everyone else. 

If you know how to call the current user only to show and then average of everyone else that would be awesome.

Let me know if you need any more info.

Thanks in advance!


Viewing all articles
Browse latest Browse all 37670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>