Creating getGroups SQLQuery