--- whoisquilty <[EMAIL PROTECTED]> wrote:

> I've got a table that has a record id and a timestamp written to it
> every time a user lands on the page.
> 
> The table is structured:
> 
> rankid (each row gets its own id)
> vidno (the access_time
> 
> I'm at a loss as to how to do this? Do I use a SUM() in the query
> statement? If so, I have no idea how to apply it to the query and
> remove the multiple rows of each id to display the unique vidno's.

OK.  Your table is a log to show when a page is accessed.

SELECT rankid, COUNT(*) as popular FROM tablename GROUP BY popular ORDER BY
popular DESC LIMIT 10;

Shows the 10 most popular pages.  You can limit the range of the access time in
the WHERE clause using the BETWEEN operator.

SELECT rankid, COUNT(*) as popular FROM tablename WHERE vidno BETWEEN
'startdate' AND 'enddate' GROUP BY popular ORDER BY popular DESC LIMIT 10;

Naturally 'startdate' and 'enddate" need to have reasonable values with a
correct format (YYYY-MM-DD HH:MM:SS) and tablename needs to be specified.

James

Reply via email to