Implemented basic SQL target ranking.