Quantcast
Channel: Rank rows using weighted average with multiple sub queries - Database Administrators Stack Exchange
Browsing all 3 articles
Browse latest View live

Answer by DBeck for Rank rows using weighted average with multiple sub queries

Here is the solution to the problem:SELECT * FROM ( SELECT student_id, avg, exam,(exam) + (avg) as total, (@rn := @rn + 1) AS rank FROM (SELECT student_id, ( SELECT AVG(g.grade) / 100 * 40 FROM grades...

View Article



Answer by dnoeth for Rank rows using weighted average with multiple sub queries

The query you posted is actually running without syntax errors?You need an average over a CASE like this:SELECT * FROM ( SELECT student_id, avg, exam,(exam) + (avg) as total, (@rn := @rn + 1) AS rank...

View Article

Image may be NSFW.
Clik here to view.

Rank rows using weighted average with multiple sub queries

So what I want to do, is to rank students based on their weighted average which will be calculated by separating the grades based on the type (whether "exam" or "not exam). The average for both will...

View Article
Browsing all 3 articles
Browse latest View live


Latest Images