Click here to Skip to main content
16,016,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
sir/mam can I know how can I get the rank function in my SQL
I have tried in my SQL this the code I have tried but its showing error plz help me
SELECT subjects,names, marks, rank()
over ( partition by subjects order by marks desc )
AS 'rank' FROM result;
many people are saying that there is no over clause function in MySQL so how can i get rank function sir

What I have tried:

SELECT subjects,names, marks, rank() 
over ( partition by subjects order by marks desc ) 
AS 'rank' FROM result;
many people are saying that there is no over clause function in MySQL so how can i get rank function sir
Posted
Updated 24-Apr-19 9:26am
Comments
[no name] 24-Apr-19 8:35am    
a.) "it is showing error" ---> What is the error?
b.) One of the mySQL Tutorial: A Guide to MySQL RANK Funtion By Practical Examples[^]

Just get the syntax right - see the documentation A Guide to MySQL RANK Funtion By Practical Examples[^]
Try this
SQL
SELECT subjects,names, marks, rank() 
over ( partition by subjects order by marks desc ) my_Rank
FROM result;
I've removed the AS and given it a name that is not a reserved word.
If it still doesn't work then it's likely that you are using an out-of-date version of MySQL as the "many people" who are saying there is no over clause in MySQL are wrong.
 
Share this answer
 
v2
Comments
[no name] 24-Apr-19 13:14pm    
Should work, a 5.
Maciej Los 24-Apr-19 15:20pm    
Agree!
 
Share this answer
 
Comments
[no name] 24-Apr-19 15:37pm    
Also good, a 5
Maciej Los 24-Apr-19 15:50pm    
Thank you, Bruno.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900