Computed column using divide

The code is written in X++ and showcases how to compute a field dynamically using a calculation based on two other fields. This technique can be particularly useful when working with views that require real-time calculations 

/// <summary>
///     Computed column to calculate ComputedField using divide
/// </summary>
/// <returns>A string expression that represents computed column</returns>
public static str calcComputedField()
{ TableName viewName = tableStr(ViewName); str tableName1Ds = identifierStr(TableName1);
str TableName2Ds = identifierStr(TableName2);
str fieldName1 = SysComputedColumn::returnField(viewName, tableName1Ds, fieldStr(TableName1, fieldName1));
str fieldName2 = SysComputedColumn::returnField(viewName, TableName2Ds, fieldStr(TableName2, fieldName2));
return SysComputedColumn::if( SysComputedColumn::equalExpression(fieldName2, SysComputedColumn::comparisonLiteral(0)),
SysComputedColumn::comparisonLiteral(0), SysComputedColumn::divide(fieldName1, fieldName2));
}

SQL translates into

(CASE WHEN T2.FieldName2 = 0 THEN 0 ELSE (T1.FieldName1) / (T2.FieldName2) END)