SELECT page, referred, ip, hit_date, min(hit_time) as 'thetime', server_port, remote_port FROM pagehits GROUP BY session ORDER BY hit_date DESC, hit_time DESC