Rewrited an SQL query in DB.java