This will return the students’ rank, student ID, and GPA.
set @rownum := 0;
SELECT @rownum := @rownum + 1 AS rank, student_id, gpa
FROM `students` ORDER BY gpa DESC
More Related Contents:
- Join vs. sub-query
- Find records from one table which don’t exist in another
- How do I update if exists, insert if not (AKA “upsert” or “merge”) in MySQL?
- Natural Sort in MySQL
- MySQL get row position in ORDER BY
- Comparing date ranges
- Subqueries vs joins
- MySQL Results as comma separated list
- MySQL unknown column in ON clause
- MySQL not using indexes with WHERE IN clause?
- SQL: Find the max record per group [duplicate]
- Group by month and year in MySQL
- calculate a sum of type time using sql
- MySQL: Transactions vs Locking Tables
- MySQL: What is a reverse version of LIKE?
- Remove duplicates using only a MySQL query?
- Group by date only on a Datetime column
- Finding the next available id in MySQL
- How exactly does using OR in a MySQL statement differ with/without parentheses?
- MySQL: How to copy rows, but change a few fields?
- How to renumber primary index
- Query that ignore the spaces
- MySQL select where column is not empty
- Is it possible to have a default parameter for a mysql stored procedure?
- mysql automatically store record creation timestamp
- update columns values with column of another table based on condition [duplicate]
- MySQL GROUP BY behavior
- Update multiple rows with one query?
- I want to copy table contained from one database and insert onto another database table
- How do MySQL views work?