modifying sql queries to match documentation