i have a sql query:
select id, name from table order by name
result looks like this:
52 arnold
33 berta
34 chris
47 doris
52 emil
for a given id=47 how can i determine the position in the result set? the result should be 4 because:
52 arnold
33 berta
34 chris
are before (47, doris) and id=41 is on the 4th position in the result set.
How to do this in SQL? How in HQL? In a pagination example, do i have to execute 2 statements or is there a solution where i can retrieve exactly that window which contains the row with id=47?
postgreSQL and java