def _add_as_gamma_to_case_statement(case_statement: str, gamma_col_name):
    """As the correct column alias to the case statement if it does not exist

    Args:
        case_statement (str): Original case statement

    Returns:
        str: case_statement with correct alias
    """
    sl = case_statement.lower()
    sl = sl.replace('\n', ' ').replace('\r', '')
    sl = sl.strip()
    if sl[-4:] != ' end':
        last_end_index = sl.rfind(' end ')
        sl = sl[:last_end_index + 5]
    return f'{sl} as gamma_{gamma_col_name}'
