Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

comparing and adding row data

Status
Not open for further replies.

azeemkhn

IS-IT--Management
Jan 15, 2020
6
QA
[URL unfurl="true"]https://res.cloudinary.com/engineering-com/raw/upload/v1579356038/tips/sampledata.csv_lhtraf.xlsx[/url]


Please guide:

1- I have to compare 'MOVINGAVERAGE' column of current row with next row until 'MOVINGAVERAGE' column of next row has greater value than previous column.

2- lets say, there are 12 rows as mentioned below with red colored, having continuous greater value then previous, then I need difference of last which is maximum value and first one which is lowest value. For example: (max value - min value) (817.55 - 602 = 215.55).

Asset Datetime MovingAverage
4042 12.01.2020 06:32:30 330.09
4042 12.01.2020 06:34:09 384.91
4042 12.01.2020 06:37:45 439.45
4042 12.01.2020 06:39:20 493.64
4042 12.01.2020 06:40:48 547.82
4042 12.01.2020 06:43:53 602
4042 12.01.2020 06:45:23 622.45
4042 12.01.2020 09:24:10 639.91
4042 12.01.2020 09:29:09 662.45
4042 12.01.2020 09:32:27 681.18
4042 12.01.2020 09:33:58 701.36
4042 12.01.2020 10:45:06 720.09
4042 12.01.2020 10:49:31 737.55
4042 12.01.2020 10:51:29 757.27
4042 12.01.2020 10:52:54 777.36
4042 12.01.2020 10:54:28 797.82
4042 12.01.2020 10:55:53 817.55

4042 12.01.2020 10:57:15 816.45
4042 12.01.2020 10:58:40 741.45
4042 12.01.2020 11:00:39 666.82
4042 12.01.2020 11:02:03 592.18
4042 12.01.2020 11:03:31 517.18
4042 12.01.2020 11:05:04 443.27
 
While it can be done with pure ANSI-SQL, I would write a T-SQL cursor.

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


 
You posted this question in another forum.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top