|
Posted by Hugo Kornelis on 04/21/06 23:02
On 21 Apr 2006 06:12:15 -0700, sucaba.r@gmail.com wrote:
>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.
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
Navigation:
[Reply to this message]
|