How to write a case statement in sql server for the status change
Posted on 2011-09-20
Hi Please help me in writing the query for the following:
I have a scenario where i need to write the query for status change.
we have 2 columns one is Id column which populates the parent and child id c1, c2, c3, c4 values and Status with Yes or NO. If there is any change in parent Id value, then it populates with the 5 alpha numeric value like '1ad2h' in a row and if there is a change in child value ' then it populates with the value which contains alphabet 'v' in it in one of the 5 alpha numeric values like for eg ' 2V3w3'. We need to identify the change in the child values and if there is any change as the child value is identified by 'v' alphabet I guess in case statement we have to use wild characters to get the change value then the status column should be updated with Yes or Y.
Similiarly if Parent value and child values does not have any v value in it then it should return N or no
P1 c1 c2 c3 status
'a2bd3' 'a2cdv' 2ah88' 'dk23k' 'Y'
'd2ks2' 'ekdkd' 'dkks2' 'd2kdk' 'N'
Like wise there are different elements like java , cobol etc each have different parent values and within the parent values we have 3 Child values. and the scenario will be the same as stated above....
Please gimme some idea how to write the query for this scenario...