Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
postgresql method not working in codeigniter model

So I am computing the variance of my data in my project, I have found out that there is a method var_samp() in postgresql that automatically computes it but it doesn't seem to work in my code. It gives me an error that says:

Severity: Warning

Message: pg_query(): Query failed: ERROR: syntax error at or near "'variance'" LINE 4: VAR_SAMP(total_score) AS 'variance', ^

Filename: postgre/postgre_driver.php

Line Number: 242

here is the table in my database: results table in databse

and here is the code of my model:

 public function computeVariance($exam_no){
        $query = $this->db->query("SELECT COUNT(total_score) AS N,
        SUM(total_score) AS sum,
        AVG(total_score) AS mean,
        VAR_SAMP(total_score) AS 'variance',
        MIN(total_score) AS minimum,
        MAX(total_score) AS maximum
        FROM results
        WHERE exam_no = '$exam_no';");

        return $query->result(); 

    }

Can someone tell me why the method var_samp() not working?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda