Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Compare values in result set.

Author  Topic 

FeistDon
Starting Member

2 Posts

Posted - 2007-09-11 : 18:09:58
This is my first post and I am probably not using the correct terminology but I will try. I want to compare the value of one of my fields in a result set to the value of the same column/field, but from the previous row in the result set. I am trying to identify the row in the result set when the value in a specified column changes value. I want to identify this row by placing a 1 in the last column. If that value did not change, then place a 0 in the last column.
I am not sure if this will make sense to anyone out there. Please let me know if more clarification is needed and I will try to provide it. Thanks for all your help in advance.

Don

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2007-09-11 : 18:16:06
you need to divide the problem in sequence then it will be clear to you what needs to be done

--------------------
keeping it simple...
Go to Top of Page

FeistDon
Starting Member

2 Posts

Posted - 2007-09-13 : 08:44:16
I found that you can use a CURSOR to loop through the rows in the result set. Then I was able to store the value of the column in a variable and fetch the next row and compare the two.
Go to Top of Page
   

- Advertisement -