Question: How C for loop having cond-expression expressed as an expression which is contextually convertible to bool work ?

Why loop stops when x is got assigned value Zero ?

```
#include <stdio.h>

int decreaseVal(int i){

    printf("deccrease val:  %d  \n",i);

    return --i;
}

int main () {
   // for loop execution

   int x;
   for( int a = 2; x=decreaseVal(a);a--) {

      printf("value of a: %d  \n",a);
   }

   return 0;
}

```

Answer: 
As you said: count distinct values up to 5th underline:

```
SQL> with test (col) as
  2    (select '2020/2021_A22_3_1_10_ACP302_0082' from dual union all
  3     select '2020/2021_A22_3_1_10_ACR301_01'   from dual union all
  4     select '2020/2021_A22_3_1_10_ACR302_01'   from dual
  5    )
  6  select count(distinct(substr(col, 1, instr(col, '_', 1, 5)))) cnt
  7  from test;                             ^         ^      ^
                                            |         |      |
       CNT                              position   underline  5th
----------
         1

SQL>

```
We can use `REGEXP_REPLACE` here as one option:

```sql
SELECT REGEXP_REPLACE(MARKSHEET_ID, '_[^_]+_[^_]+$', '') AS NEW_MARKSHEET_ID
FROM yourTable;

```