--- In [email protected], James Keeline <[EMAIL PROTECTED]> wrote:
>
> --- 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
>

James - I tried your first option (which suits my needs best) and it
tells me that it "can't group on popular". I also tried a few
variations but it still gave the same results.

Is that the right column to be grouping? Or should I be grouping
'vidno' as that's the one that I'll be using to join other tables?

Jeremy

Reply via email to