Pitipaty
Pitipaty

Reputation: 329

Return SQL Row Position but sort it before

Ok guys so I'm basically ordering the SQL Table like this:

"SELECT * FROM tablelevel ORDER BY prestige DESC, level DESC;"

And I Print the Table in a Scoreboard and it's all fine.

The problem is, now I wanted to get a position from a "playerID". Something like (What i'm about to write is just an example and doesn't work):

1st -> ("SELECT * FROM tablelevel ORDER BY prestige DESC, level DESC;") // Sort it

2nd -> ("SELECT * FROM "1st" WHERE playerID = 'x' ") // Get Pos

Is it possible to get the position of a row without adding a column with the position?

Thanks in Advance!

Upvotes: 0

Views: 64

Answers (1)

CL.
CL.

Reputation: 180182

The simplest way to get the position is to create a temporary table, and use that table's rowid:

CREATE TEMPORARY TABLE scoreboard AS
SELECT * FROM tablelevel ODER BY prestige DESC, level DESC;

SELECT * FROM scoreboard WHERE rowid = ?;

Upvotes: 1

Related Questions