I have two tables with one named att as follows
CREATE TABLE att (
SID varchar(50) NOT NULL,
CID varchar(50) NOT NULL,
Date date NOT
DELIMITER $$
CREATE TRIGGER `att_up` AFTER UPDATE ON `attentance`
FOR EACH ROW
BEGIN
SET @zeros = 0;
SET @ones = 0;
SET @total = 0;
SET @atted = 0;
(SELECT (8-SUM(h1)+SUM(h2)+SUM(h3)+SUM(h4)+SUM(h5)+SUM(h6)+SUM(h7)+SUM(h8)) INTO @zeros FROM attentance WHERE StudID=NEW.StudID);
(SELECT SUM(h1+h2+h3+h4+h5+h6+h7+h8) INTO @ones FROM attentance WHERE StudID=NEW.StudID);
(SELECT (SUM(8-(h1+h2+h3+h4+h5+h6+h7+h8))+ SUM(h1+h2+h3+h4+h5+h6+h7+h8)) INTO @total FROM attentance WHERE StudID=NEW.StudID);
SELECT (((@zeros-@ones)/@total)/100) INTO @atted FROM (SELECT 1) AS x;
END$$