getting correct number of rownumber for many to one table?

getting correct number of rownumber for many to one table?

totaljjtotaljj Posts: 1Questions: 0Answers: 0

I have many to one relationship between two tables in Oracle(USER, GROUP).

If group1 has two users and group2 has one user, I would get thress records running below query.

    SELECT * FROM (
            SELECT ROWNUM RNUM, OQ.*
                FROM (select g.*, u.* from group g left join user u on g.id= u.group_id) OQ)
            WHERE RNUM BETWEEN #{start_index} AND #{end_index}

I need to have start_index 0 and end_index 3 because I want to have group1 only.
If group1 has three USERS I need to have end_index 4.

Does anyone know how to calculate end_index depending on the data on many table?

This discussion has been closed.