title: FUNCTION "SUM does not exist"
body: <p>I am using mysql 5.5.11, when i execute the script below</p>
  
  <pre><code>INSERT INTO payments(created,  Amount,  user,  Remarks,  orderid,  paymethod) 
  VALUES('2016-09-03', 0.0, 'admin', '', 4, 'Cash');
  </code></pre>
  
  <p>I get error</p>
  
  <blockquote>
    <p>SQL Error: FUNCTION mydb.SUM does not exist. Check the 'Function Name
    Parsing and Resolution' section in the Reference Manual</p>
  </blockquote>
  
  <p>This is the table schema</p>
  
  <pre><code>CREATE TABLE payments (
    ID         int AUTO_INCREMENT NOT NULL,
    OrderID    int,
    Amount     decimal(11,2),
    Created    varchar(20),
    Remarks    varchar(160),
    user       varchar(60),
    PayMethod  varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci,
    /* Keys */
    PRIMARY KEY (ID)
  ) ENGINE = InnoDB;
  </code></pre>
  
  <p>What could be the cause of the error</p>
  
  <p>This is the trigger attached to the table</p>
  
  <pre><code>BEGIN
    /* Trigger text */
    UPDATE Orders Set Paid =(Select SUM (Amount) From Payments AS p Where p.OrderID  = Orders.ID),PayMethod =new.PayMethod  WHere Orders.id = new.OrderID;
     UPDATE Orders Set Bal = Total - Paid  WHere Orders.id = new.OrderID;
  END
  </code></pre>