Home Forums SQL Server 2008 T-SQL (SS2K8) Help with Count over days (but not per day) ... the total up until that day through the date range. RE: Help with Count over days (but not per day) ... the total up until that day through the date range.

  • diamondgm (10/1/2012)


    I believe Jeff talks about this "triangular join" in the article I referenced.

    I don't think that its a triangular join - no subquery really.

    It looks like a moficifation of the CROSS JOIN method of running total computation.

    Instead of a filtered CROSS JOIN, the INNER JOIN condition is expanded.

    This is something that Jeff did not cover in his article as far as I can remember.

    This is my understanding; I'm open to correction.

    You're correct. It's not a "triagular join". It's worse. It's a full accidental cross join. Look at the execution plan. You have 5 rows of data but one of the arrows coming off the table has 25 rows. If you add one more row to the data, that arrow jumps to 36, as expected with a cross join.

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