Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

237
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda