Fix for #2247 | Use correct column when calculating next sequence value

See #2247 for more details.