You can iterate through the table using a cursor.
The cursor can allocate the value(s) from the column(s) in the row to SQL variables.
Then for every row you make your filtering and then you make whatever you want with the results.
-- Create a cursor that iterates through the table and only reads the 'mass' column
DECLARE C1 CURSOR FOR
SELECT mass FROM masses
DECLARE @current decimal
OPEN C1
-- Copy the value from the 'mass' column to a vaiable
FETCH NEXT FROM C1 INTO @current
WHILE @@fetch_status = 0
BEGIN
-- Select the rows that have mass = current row mass + 21
SELECT * -- This ca be improved by selecting only the rows you need
FROM masses
WHERE mass = @current + 21
FETCH NEXT FROM C1 INTO @current
END
CLOSE C1
DEALLOCATE C1
In the nested select you can then copy all the rows to your destination table, e.g. by changing this lines:
INSERT INTO DESTINATION_TABLE(row1, row2, ..., rown)
SELECT (row1, row2, ..., rown)
FROM masses
WHERE mass = @current + 21