Sum Accumulating Data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hugo Kornelis

    #16
    Re: Sum Accumulating Data

    On 21 Apr 2006 06:12:15 -0700, sucaba.r@gmail. com wrote:
    [color=blue]
    >I too am confused. :-) I'll try and explain what I mean. Here's the
    >table data again, notated on the right with asterisks that count as
    >legitimate data points:
    >
    >1 - 239.21 *
    >2 - 239.55 *
    >3 - 240.30 *
    >4 - 0.35
    >5 - 0.44 *
    >6 - 0.53 *
    >7 - 1.20 *
    >8 - 2.40 *
    >9 - 0.25
    >
    >So the uptime query should return 7, as the machine was reset at
    >location 4 and 9.
    >
    >Sorry for the confusion.[/color]

    Hi sucaba,

    Slight modification of Erland's suggestion (it was thus far unclear if
    the "first" data point had to be included, since there's no "previous"
    value to compare to - Erland apparently chose to exclude it):

    SELECT COUNT(*)
    FROM @t AS a
    LEFT OUTER JOIN @t AS b
    ON a.PK = b.PK + 1
    WHERE a.Amount > b.Amount
    OR b.Amount IS NULL


    --
    Hugo Kornelis, SQL Server MVP

    Comment

    • Tom Moreau

      #17
      Re: Sum Accumulating Data

      And what is wrong with entry 9?

      --
      Tom

      ----------------------------------------------------
      Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
      SQL Server MVP
      Toronto, ON Canada
      ..
      <sucaba.r@gmail .com> wrote in message
      news:1145625135 .604955.307690@ i40g2000cwc.goo glegroups.com.. .
      I too am confused. :-) I'll try and explain what I mean. Here's the
      table data again, notated on the right with asterisks that count as
      legitimate data points:

      1 - 239.21 *
      2 - 239.55 *
      3 - 240.30 *
      4 - 0.35
      5 - 0.44 *
      6 - 0.53 *
      7 - 1.20 *
      8 - 2.40 *
      9 - 0.25

      So the uptime query should return 7, as the machine was reset at
      location 4 and 9.

      Sorry for the confusion.

      Comment

      • Erland Sommarskog

        #18
        Re: Sum Accumulating Data

        Tom Moreau (tom@dont.spam. me.cips.ca) writes:[color=blue]
        > And what is wrong with entry 9?[/color]

        0.25 < 2.40

        or so I guess.

        But it's difficult when sucaba.r does not really seem to have a grip
        on it him/herself.

        Maybe because it's some class assignment, and not a real-world case, who
        knows.



        --
        Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

        Books Online for SQL Server 2005 at

        Books Online for SQL Server 2000 at

        Comment

        • Tom Moreau

          #19
          Re: Sum Accumulating Data

          The specs are confusing - and fluid. My guess is if he wants 7 so bad, then
          this is the solution:

          SELECT 7

          --
          Tom

          ----------------------------------------------------
          Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
          SQL Server MVP
          Toronto, ON Canada
          ..
          "Erland Sommarskog" <esquel@sommars kog.se> wrote in message
          news:Xns97AD85A 38BDF9Yazorman@ 127.0.0.1...
          Tom Moreau (tom@dont.spam. me.cips.ca) writes:[color=blue]
          > And what is wrong with entry 9?[/color]

          0.25 < 2.40

          or so I guess.

          But it's difficult when sucaba.r does not really seem to have a grip
          on it him/herself.

          Maybe because it's some class assignment, and not a real-world case, who
          knows.



          --
          Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

          Books Online for SQL Server 2005 at

          Books Online for SQL Server 2000 at


          Comment

          • sucaba.r@gmail.com

            #20
            Re: Sum Accumulating Data

            My apology for not making myself clear enough, and yes it's real-world.
            Thanks again for all the help guys.

            Comment

            • Tom Moreau

              #21
              Re: Sum Accumulating Data

              So why is item #1 to be considered, yet items #4 and #9 are bad? Item #1 is
              the beginning of one of these reset sequences (since there are no data
              before it), yet it is considered to be valid.

              --
              Tom

              ----------------------------------------------------
              Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
              SQL Server MVP
              Toronto, ON Canada
              ..
              <sucaba.r@gmail .com> wrote in message
              news:1145881910 .902935.13460@i 39g2000cwa.goog legroups.com...
              My apology for not making myself clear enough, and yes it's real-world.
              Thanks again for all the help guys.

              Comment

              Working...