A
A
Artur Atnagulov2015-01-05 20:33:29
MySQL
Artur Atnagulov, 2015-01-05 20:33:29

How to translate this query from MySQL to PostgreSQL?

There is a request:

SET @i=0;

SELECT * FROM (
SELECT *, @i:[email protected]+1 AS 'place'
 FROM test 
 ORDER BY score DESC
) t1
 WHERE id = 1;

How will it look like in PostgreSQL?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2015-01-05
@atnartur

SELECT * FROM (
SELECT *, row_number() OVER(ORDER BY score DESC) AS 'place'
 FROM test 
 ORDER BY place
) t1
 WHERE id = 1;

?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question