Jump to content

[SOLVED] Need Math Help


Heavy_Kevy

Recommended Posts

OK what im trying to get done is the percent of questions that were answered.  Now the number of questions are in one table and the amount of questions answered are in a separate table.  So I add up all the questions and divide it by 100 in one record set.  Then I add up all the answers in its own record set.  But what i cant seem to do is multiply them together.  Now i tried to simplify this by putting them both into one record set like this but it kept returning 0.

 

SELECT ((COUNT(rm.MpText) / 100) * COUNT(td.Data)) * 100

FROM 'tours' AS t

LEFT JOIN route_mps AS rm ON rm.RouteID = t.RouteID

LEFT JOIN tour_data AS td ON td.TourID = t.RouteID

WHERE t.RouteID = $RouteID AND td.Data > 0

GROUP BY RouteID

 

Any help would be greatly appreciated.

Link to comment
Share on other sites

Try something like this:

 

SELECT ((COUNT(rm.MpText) / 100) * COUNT(td.Data)) * 100

FROM 'tours' AS t

LEFT JOIN route_mps AS rm ON rm.RouteID = t.tours    # You did "...FROM 'tours'..." so the first join should be tours.

LEFT JOIN tour_data AS td ON td.TourID = t.RouteID

WHERE t.RouteID = $RouteID AND td.Data > 0

GROUP BY RouteID

Link to comment
Share on other sites

Thanks for the reply but that didnt work.  But I changed this line to

 

LEFT JOIN tour_data AS td ON td.TourID = t.TourID

 

And im getting an answer its just not the one i want. I want to see 40 but right now its coming up with 16.

Now the math looks like this COUNT(rm.MpText)/100 = .100 because there are 10 questions.  COUNT(td.Data) = 4 because only 4 questions were answered out of the 10.  NOw .100 * 4 should be .4000 but for some reason thats not what coming up. any ideas?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.