On 10/3/07, Jimmy Choi <yhjchoi@gmail.com> wrote:
> I expect to get the following result set:
>
> metric_type | result
> ------------+-------
> 0 | 2
> 1 | 3
Try:
SELECT metric_type
, SUM(CASE metric_type
WHEN 0
THEN 1 / val
WHEN 1
THEN val
END) AS RESULT
FROM metrics
GROUP BY metric_type
ORDER BY metric_type