Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!