Have you been successful yet? I'd like to see your solution if you have. I toyed with this for a couple of minutes, but quickly realized that your algorithm can best be stated in pseudo-code like this:
getCol3( rownum )
{
if( 0 = col2(rownum) ) Then
return getCol3(rownum-1) - col1(rownum);
else
return col2(rownum);
}
which is a *recursive* procedure. Some DBMs support recursive queries (Oracle and DB2 for instance), but I'm not sure even they would work here as they tend to recurse on *existing* field values, not on generated values like you want here. Check out the CONNECT BY clause if you're interested. I'm inclined to think Colin is correct here; I SERIOUSLY doubt this can be done without procedures. I have similar requirements in my tables, but have resigned myself to putting the table updates into loops within code. Let us know if you do figure out a clever way. Good luck. David