title: mysql group by week on two years
body: <p>Hi im writing a query for get results for a area chart.i have datas for two years. i use mysql group by date for get daily results, but when i use group by week icannot find a way to seperate two years weekly datas becoz it returns with week numbers like 4,5</p>
  
  <p>my code is</p>
  
  <pre><code>     $results=mysql_query("SELECT SUM(rate) as rate, week(rdate) as rdate 
      FROM cpustats 
      WHERE server_id='$server_id' 
      GROUP BY week(rdate)") or die(mysql_error());
      $data3='';
      $data4='';
      while ($row = mysql_fetch_array($results)) {
          //one day has lots of records i devide that for get average
         $rk=mysql_query("SELECT rate as rdate FROM cpustats 
      WHERE server_id='$server_id' 
      AND week(rdate)='".$row['rdate']."'") or die(mysql_error());
         $nr=mysql_num_rows($rk);
         //here has issue which shows sum of two years same week data
         $usage=round($row['rate']/$nr,2);
  
         //tfunction return start and end of week by passing week number
         $week=getStartAndEndDate($row['rdate']);
  
         $data3[] = "'".$week."'";
         $data4[] = "$usage";
  
  }
  </code></pre>
  
  <p>can anyone help me to get seperate weekly datas for two years pls</p>