EQ-1576 Fix SQL for Oracle DB