sql - Query to find the salary of an employee -


i'm writing query in oracle follows

select rownum salary, (rownum + 1) increment,(rownum + (rownum + 1)) total dual; 

and result follows

salary   increment   total ---------------------------     1            2        3 

but i'm trying following result

salary   increment   total ---------------------------     1            2        3     3            2        5     5            2        7 

here in above result total of 1st row become salary in next row, increment amount 2 instance, , total of 2nd row become salary in 3rd row , on. me in getting result.

this query give result. use connect level create 3 rows. use lag() retrieve previous total. don't know if looking for.

select nvl(lag(totalaux) on (order salaryaux), salaryaux) salary,        increament,        totalaux total   (   select level        salaryaux,           2           increament,         (level * 2)+1 totalaux   dual   connect level <=3); 

output

    salary increament      total ---------- ---------- ----------          1          2          3          3          2          5          5          2          7 

Comments