Skip to content

Instantly share code, notes, and snippets.

@harisankarh
Created March 12, 2018 16:18
Show Gist options
  • Save harisankarh/4d3fec704ccfe200cdbc7ad492976837 to your computer and use it in GitHub Desktop.
Save harisankarh/4d3fec704ccfe200cdbc7ad492976837 to your computer and use it in GitHub Desktop.
SELECT *,
SUM(d0*dscores_0) OVER () AS dw2_00,
SUM(d0*dscores_1) OVER () AS dw2_01,
SUM(d1*dscores_0) OVER () AS dw2_10,
SUM(d1*dscores_1) OVER () AS dw2_11,
SUM(dscores_0) OVER () AS db2_0,
SUM(dscores_1) OVER () AS db2_1,
CASE
WHEN (d0) <= 0.0 THEN 0.0
ELSE (dscores_0*w2_00 + dscores_1*w2_01)
END AS dhidden_0,
CASE
WHEN (d1) <= 0.0 THEN 0.0
ELSE (dscores_0*w2_10 + dscores_1*w2_11)
END AS dhidden_1
FROM {inner subquery}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment