Home Forums SQL Server 2008 T-SQL (SS2K8) CASE Statement in SELECT clause to convert into the where clause RE: CASE Statement in SELECT clause to convert into the where clause

  • worker bee (11/14/2012)


    I updated with no results that are different. I still get two rows, 26 is the TAXABLE, TAX-DEF and the other is 27 SOLE, JOINT, OTHER. I had tried this before. Here is the query and the results;

    select distinct

    CASE aor.optional_category_cd

    WHEN '26' THEN aoc.optional_class_nm

    END AS AccountType,

    CASE aor.optional_category_cd

    WHEN '27' THEN aoc.optional_class_nm

    END AS AccountType

    from

    ACCOUNT_OPT_REF aor inner join ACCOUNT_OPT_CLASS aoc ON aor.Optional_Category_Cd = aoc.Optional_Category_Cd and

    aor.Optional_Class_Cd = aoc.Optional_Class_Cd

    where

    aor.Optional_Class_Cd > 1

    AccountType AccountType

    TAXABLE NULL

    NULL SOLE

    TAX-DEFERRED/NOT TAX ON WDRAWL NULL

    NULL JOINT

    TAX-DEFERRED & TAX ON WDRAWL NULL

    NULL OTHER

    NULL NULL

    As I said before I can't see your screen, I have no idea what your ddl is like, I have no sample data to work with and I have no idea what you want as output. Please see the first article in my signature about best practices when posting questions.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/