• SELECT CustomerNumber,

    SUM(CASE WHEN [YearMonth] BETWEEN 201401 AND 201412 THEN TotalAmount ELSE 0 END) AS Sales_2014,

    SUM(CASE WHEN [YearMonth] BETWEEN 201201 AND 201312 THEN TotalAmount ELSE 0 END) AS Sales_2012_2013,

    SUM(CASE WHEN [YearMonth] <= 201112 THEN TotalAmount ELSE 0 END) AS Sales_Prior_To_2012

    FROM dbo.tblYearMonthTotals

    GROUP BY CustomerNumber

    HAVING

    SUM(CASE WHEN [YearMonth] BETWEEN 201401 AND 201412 THEN TotalAmount ELSE 0 END) > 0 AND

    SUM(CASE WHEN [YearMonth] BETWEEN 201201 AND 201312 THEN TotalAmount ELSE 0 END) = 0 AND

    SUM(CASE WHEN [YearMonth] <= 201112 THEN TotalAmount ELSE 0 END) > 0

    Edit: Frankly in this kind of situation, I think the YYYYMM actually makes it easier to code than a date/datetime, but maybe that's just me.

    Edit2: I also assumed the possibility of returns, for example, +$125.00 in one month, then -$125.00 in the next month, resulting in a net of $0.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.