Thanks for the solution. It works as long as the a and b doesnt equal to 0. It is possible that we may not have to delete any top and bottom records and in that case the value for top and bottom rows will be 0.
The offset and length fields in ${parameter:offset:length} expansions are arithmetic expressions, and therefore do not need a dollar sign, so this should work too: