select - How to Rank in MySQL Using a WHERE clause and UNION ALL -


I need some help from a MySQL query. I am trying to rank the participants using a WHERE clause. Therefore, I want to rank novice, intermediate, and different experienced people. For example:

  Rank name grade type -------------------------------- - - 1 Bob 98 Nov 2 Jill 88 Newbie 3 Jimmy 42 Nov 1 Mark 87 Intermediate 2 Scott 85 Intermediate 3 Gym 77 Intermediate 1 Jane 90 Advanced 2 John 89 Advanced 3 Josh 87 Advanced  

Tried:

  SET @ rank = 0; (SELECT @rank: = @ rank + 1s rank, name, grade, type myTable WHERE type = 'newbie' grade DESC by ORDER) UNION ALL (SELECT @Rank: = @ rank + 1s rank, name, grade, Type type from myTable = Grade DESC by 'Intermediate' order) UNION all (SELECT @rank: = @ rank + 1s rank, name, grade, type myTable WHERE type = 'veteran' by order grade by DESC)  

I think I need to set the rank again in some way. Maybe I have another problem?

Use:

  SELECT t Name, T.Grade, T. type, (* (SELECT COUNT (*) from your COUNTER, where x * and x.grade> = t.grade) from your tablet \ t  

To handle two grade columns, use it:

  SELECT t.name, t.gr1, t.grade2, t.type, (SELECT COUNT (*) Your ranking is <0 How would I rank newbie and intermediate together and differently?  

Use:

  SELECT y. *, (SELECT COUNT (*) FROM (SELECT *, Case t.type WHEN 'Advanced' then T.P. Car ELSE from the group_type as 'non-advanced' END) where x.group_type = y.group_type AND (x.grade1 + x.grade2)> = (y.grade1 + y.grade2)) by rank AS (SELECT t.name, t.gr1, t. grade2, T. type, case ttte WHEN 'advanced' then T. type ELSE YOUR_TABLE T by group typing as 'non-advanced' end)  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -