kaushal_shah26 (8/1/2012)
Hi Guys,I have a table like this
Id----------Type--------ConditionId-------isActive------SortOrder
1001-------860----------2----------------1------------1
1002-------860----------3----------------1------------0
1003-------860----------5----------------1------------Null
1004-------860----------1----------------0------------Null
1005-------860----------4----------------0------------Null
There are 3 conditions which are active. Out of those 3 conditions, 2 have sortorder value (1 and 0).
I need to write a script whereI need to update the record where condition is active but sortOrder is null (In the case above, it's conditionId 5).
I need to update the sortOrder with the next value of the maximum sortOrder for the type where isactive is 1.
so, in the case above, after the update, Id = 1003 should look lik this
1003-------860----------5----------------1------------2
I have been trying combination of queries but more I tried, more confused I got.
I would appreciate if you guys can guide me to resolve this matter.
Thanks.
Sorry, I forgot to mention that there might be case where two or more conditions are active but they do not have sort order. In the case above, If I add one more row
1006-------860----------6----------------1------------Null (conditionId = 6)
then I have two conditionId (5 & 6) that are active but sortorder is null
The final output should be
1003-------860----------5----------------1------------2
1006-------860----------6----------------1------------3
Thanks a million.