Oracle Sql Loop Through Select Statement Where Condition