'How to pass dynamic values in query CASE expression?
SELECT
req,
SUM(CASE WHEN (stage='Selected') THEN count ELSE NULL END) AS selected,
SUM(CASE WHEN (stage='Initial Selection') THEN count ELSE NULL END) AS "Initial Selection",
SUM(CASE WHEN (stage='Hr Round') THEN count ELSE NULL END) AS "Hr Round"
FROM table1
GROUP BY req
;
In the above Postgres query, the value for stage is passed statically (hard-coded) in CASE expression, how can we pass the value for stage dynamically from the result of another query?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
