title: How can i make a calculator in SQL?
body: <p>So i have this assingment in school, were i am supposed to make a tool for a DPO in a firm. The assignment is as follows: "You are required to develop an app or on-line tool where you can enter the status of the many details that the regulations states for the company. The intended user of the tool is a Data Protection Officer (DPO) or an employee responsible for data projection in general. The tool shall be able to handle input from more than one company and more than one audit for the individual company. The tool shall be able to calculate the level of compliance to the GDPR." So as for the calculator i thought about a solution, where the DPO for a given company, can give one of the 12 regulations either a 1 or 0, where 1 is that the regulation is complied and 0 is not. So i wanted to take the sum and then divide with 12, to get the compliance average number. But how do i do this in SQL?
  As of now, i have already made the comany, auditor and regulation table, which looks like this:</p>
  
  <pre><code>    CREATE TABLE IF NOT EXISTS`Companies` (
      `idCompanies` INT NOT NULL,
      `cvr_nr` INT NULL,
      `Dato` DATE NULL,
      PRIMARY KEY (`idCompanies`))
      ENGINE = InnoDB;
  
      CREATE TABLE IF NOT EXISTS `Auditors` (
        `idAuditors` INT NOT NULL,
        `Auditor_name` VARCHAR(45) NULL,
        PRIMARY KEY (`idAuditors`))
      ENGINE = InnoDB;
  
  insert into auditors values (1, "Lars Larsen");
  insert into auditors values (2, "Henrik Andersen");
  insert into auditors values (3, "Jens Andersen");
  
  drop table if exists regulations;
  CREATE TABLE IF NOT EXISTS `Regulations` (
    `idRegulations` INT NOT NULL auto_increment,
    `Regulation_name` VARCHAR(100) NULL,
    `Regulation_details` VARCHAR(400) NULL,
    PRIMARY KEY (`idRegulations`))
  ENGINE = InnoDB;
  
      insert into regulations values (null, "xx", "xxx");
      insert into regulations values (null, "xx", "xxx");
  
  #The XX are just as examples.
  
  CREATE TABLE IF NOT EXISTS `Companies_has_Regulations` (
    `Companies_idCompanies` INT NOT NULL,
    `Regulations_idRegulations` INT NOT NULL,
    PRIMARY KEY (`Companies_idCompanies`, `Regulations_idRegulations`),
    INDEX `fk_Companies_has_Regulations_Regulations1_idx` (`Regulations_idRegulations` ASC),
    INDEX `fk_Companies_has_Regulations_Companies1_idx` (`Companies_idCompanies` ASC),
    CONSTRAINT `fk_Companies_has_Regulations_Companies1`
      FOREIGN KEY (`Companies_idCompanies`)
      REFERENCES `Companies` (`idCompanies`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_Companies_has_Regulations_Regulations1`
      FOREIGN KEY (`Regulations_idRegulations`)
      REFERENCES `Regulations` (`idRegulations`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  </code></pre>