How to SELECT sum of numbers less than 30 and sum of numbers greater than 30?

oracle, sql, teradata

Solution

Something along these lines (correct the syntax for your environment):

SELECT
    sum(case when Field < 30 then Field else 0 end) as LessThan30,
    sum(case when Field > 30 then Field else 0 end) as MoreThan30
FROM
    DaTable

Problem

I'm trying to write a SELECT statement to select the sum of field but I want to return the sum of numbers less than 30 and also the sum of numbers greater than 30. I realize I can do this with two selects joined together, but I was hoping to find a "neat" way of doing it.

Original source