SQL first so I can reference it lower:
SELECT ID,
SUM(length(substr(DATA_STRING, instr(DATA_STRING,'P')+1)))
FROM DATA P, PLC PP
WHERE P.ID = PP.ID
AND instr(DATA_STRING, 'F') = 0
GROUP BY ID
The function above looks for the P in each data string and counts up how many characters are in the string.
So my problem is thus, I have two conditions that can occur, one where the data string could contain the P as in above, or when it contains a F. I need to be able to check for both and then sum up the total. The issue with the above is that I sum in a 0 if that condition when the string has an F occurs.
I almost need the equivalent of SUMIF in Excel so that I could say if when I search for P it's 0, then look for the F and add in that length and vice versa.
Please let me know if you have suggestions!
instrportion that is used in the calculation for the length would also need to change