Sql Queries for AMG database