Refactor get_takes a bit

Simplify SQL construction.