title: MySql Returns error when using function WEEK() with modes
body: <p>I have a problem that I can't make function <strong>WEEK(date, mode)</strong> to work.</p>
  
  <p>I have an SQL where I am grouping sums by year and then by week:</p>
  
  <pre><code>SELECT SUM(o.total) as total_org, SUM(o.total_eur) as total_eur, 
  WEEK(DATE_ADD(o.date_created_utc, INTERVAL 0 HOUR)) as period, YEAR(DATE_ADD(o.date_created_utc, INTERVAL 0 HOUR)) as smallerperiod, `s`.`domain`
  FROM `orders` `o`
  JOIN `shops` `s` ON `o`.`domain_id` = `s`.`id`
  WHERE `o`.`domain_id` = '5'
  GROUP BY YEAR(DATE_ADD(o.date_created_utc, INTERVAL 0 HOUR)), WEEK(DATE_ADD(o.date_created_utc, INTERVAL 0 HOUR))
  ORDER BY `smallerperiod` ASC, `period` ASC
  </code></pre>
  
  <p>Which <strong>works exactly how I want</strong> except weeks starts from number 0. I found out that mode that would work the best for me is number 3, so I tried to change my SQL to:</p>
  
  <pre><code>SELECT SUM(o.total) as total_org, SUM(o.total_eur) as total_eur, 
  WEEK('DATE_ADD(o.date_created_utc, INTERVAL 0 HOUR)', 3) as period, YEAR(DATE_ADD(o.date_created_utc, INTERVAL 0 HOUR)) as smallerperiod, `s`.`domain`
  FROM `orders` `o`
  JOIN `shops` `s` ON `o`.`domain_id` = `s`.`id`
  WHERE `o`.`domain_id` = '5'
  GROUP BY YEAR(DATE_ADD(o.date_created_utc, INTERVAL 0 HOUR)), WEEK('DATE_ADD(o.date_created_utc, INTERVAL 0 HOUR)', 3))
  ORDER BY `smallerperiod` ASC, `period` ASC
  </code></pre>
  
  <p>However it just gave me the error </p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use
    near ') ORDER BY <code>smallerperiod</code> ASC, <code>period</code> ASC</p>
  </blockquote>
  
  <p>EDIT:
  I tried to make it work without single quotes too:</p>
  
  <pre><code>SELECT SUM(o.total) as total_org, SUM(o.total_eur) as total_eur, 
  WEEK(DATE_ADD(o.date_created_utc, INTERVAL 0 HOUR), 3) as period, YEAR(DATE_ADD(o.date_created_utc, INTERVAL 0 HOUR)) as smallerperiod, `s`.`domain`
  FROM `orders` `o`
  JOIN `shops` `s` ON `o`.`domain_id` = `s`.`id`
  WHERE `o`.`domain_id` = '5'
  GROUP BY YEAR(DATE_ADD(o.date_created_utc, INTERVAL 0 HOUR)), WEEK(DATE_ADD(o.date_created_utc, INTERVAL 0 HOUR), 3))
  ORDER BY `smallerperiod` ASC, `period` ASC
  </code></pre>
  
  <p>However, it returns me the same error</p>