Home Forums SQL Server 2008 T-SQL (SS2K8) query to get the name of a product with only incremental values in the quantity column RE: query to get the name of a product with only incremental values in the quantity column

  • Nisean (12/12/2012)


    i need a query to get the names of the product which has incremental or equal values every year 2009-2012(in its QTY column)

    Product year QTY

    Computer2009100

    Computer2010200

    Computer2011300

    Computer2012400

    printer 2009100

    printer 2010 200

    printer 2011250

    printer 2012250

    flash drive2009400

    flash drive2010500

    flash drive2011700

    flash drive2012900

    monitor 2009200

    monitor 2010300

    monitor 2011250

    monitor 2012400

    keyboard 2009100

    keyboard 2010150

    keyboard 2011200

    keyboard 2012150

    -------------output----------

    Computer

    printer

    flashdrive

    What do you want to do if there's a year missing from any given product?

    --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)