Hi
I have a set of data with the following results - how do I evaluate the previous record data for bunch of columns based on a group value.
Group_id customer flag1 flag2 flag3
1 Netflix Y Auto Template
1 Netflix N Auto Template
2 Amazon Y Auto Template
2 Amazon Y Manual Template
3 ABC.com N Auto NonStandard
3 ABC.com N Auto Template
4 Blockbuster Y Auto Template
4 Blockbuster Y Auto Template
4 Blockbuster N Auto NonStandard
5 Nice.com Y Auto Template
5 Nice.com Y Auto Template
From the results above I want to write a sql to give me the group ids that do not have the flag values same - for example easy case will be group id value = 5 wher the flag1, flag2 and flag3 values are same then I want to categorize them as "PERFECT" but if there are any changes to flag1 of first record to flag1 of second record or third record then I want to categorize them as flag1value change - from my example above group id value = 1, similarly to categorize as flag2 change for group id value = 2 and flag3 change for group id value = 3.
More complex case is group id value = 4 where both flag1 and flag3 value change when compared to 3 records -
group id value can be same for 2 or more records - I dont know how I can write a sql to categorize them based on flag value comparing the first record to second , third and so on -
any help will be greatly appreciated
Great answer - I applied and got the results - I have 2 questions -
1. for more complex case group id value = 4 both flag1 and flag 3 changed I got the flags categorized as flag1changedflag3changed - without a space in between I would have expected flag1 changed and flag3 changed - if I understand the replace fuction that you used
2. also I forgot to mention in my sample data I need to add contract id and bunch of columns that gets repeated for every group id value for example
Group_id customer flag1 flag2 flag3 contract id customer_id
1 Netflix Y Auto Template 1-123 cust01
1 Netflix N Auto Template 1-123 cust01
how can I incorporate these extra columns in the sql - since I need them as well -