Single Core Count Help Needed in T-SQL

  • Dear Gurus

    Here is my scenario.... hmmm

    single call - count stockgroup IF CUSTOMER SAME BUT DIFF STOCKGROUP = 1 else 0

    multiple call - count docno If SAME STOCK GROUP = 0 ELSE 1

    docno agent STOCKGROUP customer Single Count MUltiple Count

    iv001 1 AB a 1 1

    iv001 1 BC b 1 1

    iv001 1 AB a 0 0

    iv002 2 de b 1 1

    iv003 2 ab a 1 1

    I'm stuck with tries to concat multiple column to get a distinct concat..to enable the count..

    but still having no luck...

    Anyone could give a helping hand or some tips on how to perform such manipulation in TSQL?

    Help would be deeply appreciate

    Regards,

    Terri

  • Maybe you noticed many people stepped into this thread but didn't answer you...

    I think it might help if you post some sample code (create temp tables, populate demo data) so we can understand what you're trying to achieve..

    Just my 2 cents...

  • I'm not sure what the actual question or result set is supposed to be. Please see the following... the methods there will help us help you a lot better.

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply