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

341
Views
I need help translating a script from SQL server to Postgresql to calculate odds ratios for multiple columns?

I need help adapting the code found in this previous question How can I translate a script I wrote in SQL server to compute the odds ratios to Postgresql? to include two columns in Postgresql. This is what I have as of now. I am getting syntax errors.

    --Compute the odds ratios from the model 
    SELECT a."column1", a."column2"
    a.uvs AS testuvs,
    b.uvs AS controluvs,
    CASE WHEN b.uvs > 0 THEN a.puvs / b.puvs ELSE NULL END AS odds
    INTO "bivariate_odds"
    FROM "control_group_probabilities" b
    INNER JOIN "test_group_probabilties" a ON 
    a.column1 = b.column1 and a.column2=b.column2
    WHERE a.uvs > 24 AND b.uvs > 24
    ORDER BY odds DESC

In SQL server, I would run the following script without any trouble:

    --compute the odds ratios 
    select a.column1, b.column2, a.totaluvs as totaltestuvs, a.uvs as 
    testuvs, b.totaluvs as totalcontroluvs, b.uvs as controluvs
    , odds= case when b.puvs>0.000001 then a.puvs/b.puvs else null end
    into bivariate_odds
    from test_group_probabilties a
    inner join control_group_probabilities b
    on a.column1=b.column1
    and a.column2=b.column2

The SQL server code is what I would like to express in Postgresql.

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!