I am tring to get difference between frequency, so first row minus next rows,second row minus third row,etc. However, my id in the table like below. So I cannot use minus 1 to get the previous row, and I trying  to use <, but not working,help, appreciate.
id    game   number frequency 
1      a      3        4
5      c      3        5
6      a      3        7
9      a      2        9
13     a      2        19
My query is:
SELECT t1.frequency-t2.frequency as diff 
FROM $table as t1 
JOIN $table as t2 ON t2.id < t1.id 
WHERE t1.game=a AND t1.num=2
 
     
    