OPSMN-1574: Fix the query to run on Oracle DB