Optimised SQL query for claiming ranges
requiredColumns can now return an integer to specify getting the first "n" columns