select Cts_ranks.mapid, max(trank), min(tvalue), alias
from Cts_ranks, Cts_times, Id2alias
where Cts_ranks.mapid = Cts_times.mapid 
    and tvalue != 0 
    and cryptokey = idvalue 
    and idrank = 1
group by Cts_ranks.mapid
order by max(trank);