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.