title: MySQL sales per Day, Week and Month
body: <p>Im trying to create a sales report in which the user can see sales per Day,  Week and Month.</p>
  
  <p>This is my table:</p>
  
  <pre><code>  CREATE TABLE IF NOT EXISTS `sales_act` (
    `id` int(11) NOT NULL auto_increment,
    `sale` decimal(10,2) NOT NULL default '0.00',
    `paymethod` smallint(2) NOT NULL default '0',
    `saledate` datetime NOT NULL default '0000-00-00 00:00:00',
    `status` smallint(2) NOT NULL default '0',
    PRIMARY KEY  (`id`)
  ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
  
  INSERT INTO `sales_act` (`id`, `sale`, `paymethod`, `saledate`, `status`) VALUES
  (1, '150.00', 3, '2016-07-30 14:37:25', 2),
  (2, '50.00', 1, '2016-08-14 21:38:34', 1),
  (3, '150.00', 3, '2016-08-15 14:23:21', 2),
  (4, '100.00', 1, '2016-08-15 14:25:12', 1),
  (5, '50.00', 2, '2016-08-15 14:27:31', 3);
  </code></pre>
  
  <p>I was reading here in stackoverflow some examples of this, but I cant seem to make it work, this is what I have so far, but doesnt work :(</p>
  
  <pre><code>$result = $mysqli-&gt;query('SELECT DATE_FORMAT(saledate, "%m-%Y") AS Month, SUM(sale) AS `salessum` WHERE `status` &lt; 3 GROUP BY DATE_FORMAT(saledate, "%m-%Y")'); 
  while ($row = $result-&gt;fetch_assoc()) {
  
      echo '&lt;pre&gt;';
  print_r($row);
      echo '&lt;/pre&gt;';
  
  }
  </code></pre>
  
  <p>Can someone tell me what Im doing wrong?
  Thanks in advance!! :D</p>