Fixed minor error in SQL for cross trials query so that it works in both Postgres and Oracle.