MySQL Forums
Forum List  »  Newbie

Distinct Query Help
Posted by: scott kimler
Date: June 07, 2005 10:31AM

This is my first post. I have a simple table with the following structure:

TABLE: evo_online
FIELDS:
timestamp(primary) int(15)
totIP varchar(40)
ip (index) varchar(40)
file (index) varchar(100)

Sample population:

timestamp totIP ip file
1118157449 205.206.9.123 205.206.9 /2005/06/01/offsite_links_open_new_windows
1118157447 205.206.9.123 205.206.9 /2005/06/01/offsite_links_open_new_windows
1118157446 205.206.9.4 205.206.9 /index.php
1118157445 205.206.9.123 205.206.9 /2005/06/01/offsite_links_open_new_windows
1118157444 205.206.9.4 205.206.9 /index.php
1118157442 205.206.9.4 205.206.9 /index.php
1118157437 205.206.9.141 205.206.9 /2005/05/29/sponging_it_up
1118157435 205.206.9.141 205.206.9 /2005/05/29/sponging_it_up
1118157433 205.206.9.141 205.206.9 /2005/05/29/sponging_it_up
1118157277 207.46.98.88 207.46.98 /2005/03/24/gene_altered_foods
1118157275 207.46.98.88 207.46.98 /2005/03/24/gene_altered_foods
1118157273 207.46.98.88 207.46.98 /2005/03/24/gene_altered_foods

From this example, I would like to return the full IP address and filename from each unique 3-character IP address, having the maximum timestamp value (2 rows):

207.46.98.88 /2005/03/24/gene_altered_foods
205.206.9.123 /2005/06/01/offsite_links_open_new_windows

I'm new to SQL, have been trying various SELECT DISTINCT statements, but getting only errors or the incorrect results. I'm assuming that such a query is possible. Any help would be greatly appreciated.

Options: ReplyQuote


Subject
Written By
Posted
Distinct Query Help
June 07, 2005 10:31AM
June 07, 2005 03:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.