• Gillian_Pappas2002 (12/12/2013)


    Hi. Thank you again for your response. That works very well to get rid of either status C or O, but what they want me to do is to look at all of the same customer order numbers and their status. If the same customer order number has ANY status of 'O', they do not want to see any of those customer order records. They only want to see like customer orders that All have a 'C' status.

    Below is the before and after applying your solution. They do not want to see ANY Orders 905055 because it has one with a status of 'O'. but they would want to see order AW00000253 because it doesn't have any status's of 'O". I hope this makes sense and I appreciate all of your help.

    conum colineitemnumcoitemstatconumcolineitemnumcoitemstat

    905055 1222-63-05C9050551222-63-05C

    905055 2222-63-47C9050552222-63-47C

    905055 3222-63-80C9050553222-63-80C

    905055 4222-23-72OAW000002531222-63-147C

    AW00000253 1222-63-147CAW000002532222-63-247C

    AW00000253 2222-63-247CSF000003891222-23-11C

    AW00000306 2222-23-31OSF000003902222-23-11C

    AW00000306 10222-23-72OSF000004451222-23-11C

    AW00000306 12222-23-47OSF000029943222-63-81C

    SF00000389 1222-23-11CSF000040991222-63-13C

    SF00000390 2222-23-11CSF000073145222-23-31C

    PLEASE take a few minutes and read the first link in my signature. The sample data you posted is a mess. It is impossible to tell what is what. You have multiple columns with the same name. Turn this into some actual ddl and sample data (create table and insert statements).

    This is really not a difficult query but without tables to work with we are guessing.

    _______________________________________________________________

    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/