List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:May 7 2003 5:36am
Subject:Re: mySQL Design Question
View as plain text  
In the last episode (May 06), Sam Evans said:
> I've been faced with an interesting design dilemma..  I have a pretty 
> straight forward table such as:
> 
> +------------+------------------------+----------+------------+-------------------+
> | keyid (INT) |  site (VARCHAR 250) | hits (INT) | bytes (INT) | dts 
> (DATETIME) |
> +------------+------------------------+----------+------------+-------------------+
> 
> This table will keep track of 7 days worth of data..  What I'm tasked 
> with, is to come up with a method that will take the 7 days of data, and 
> produce a top X sites over the 7 day period based on either cumulative 
> hits / bytes.
>
> For example, to show the stop 25 Websites by way of hits for the last 7 
> days.

You mean like "SELECT site, SUM(hits), SUM(bytes) FROM mytable WHERE
dts > NOW() - INTERVAL 7 DAY GROUP BY site ORDER BY SUM(hits) DESC LIMIT 25" ?

-- 
	Dan Nelson
	dnelson@stripped
Thread
mySQL Design QuestionSam Evans7 May
  • Re: mySQL Design QuestionDan Nelson7 May
  • Re: mySQL Design QuestionCurtis Maurand8 May