sdt_cod result ====== ===== 101 P 102 P 103 F 103 P 104 F 104 P 105 F 105 F 105 P 106 F 106 F 106 P. 107 F 107 F 107 P. P - Pass F- Fail here 102 & 102 are passed in first attempt.. 103 & 104 are passed in 2nd attempt 105, 106 & 107 are passed in 3rd attempt I WANT THE RESULT AS count(sdt_code) test attempt 2 1 2 2 3 3