I need to generate the below query, I am able to do everything apart from the TO_CHAR(opCase.writeoff_dt, 'mm') MOnth
Can some to help to write the Predicate for the same
select sum(dtl.ovrpymnt_case_adjstmnt_am) Adj_AM, sum(dtl.op_case_fees_am) Fees_AM , sum(dtl.ovrpymnt_case_adjstmnt_am) + sum(dtl.op_case_fees_am) Total ,
TO_CHAR(opCase.writeoff_dt, 'mm') MOnth
from ufactssys.UI_OP_WRITEOFF hdr inner join
ufactssys.UI_OP_WRITEOFF_DTL dtl on hdr.overpayment_writeoff_id =dtl.overpayment_writeoff_id
inner join UFACTSSYS.ui_op_case opCase on opcase.overpayment_case_id= dtl.op_case_id
where TO_CHAR(opcase.writeoff_dt, 'mm') >=1 and TO_CHAR(opcase.writeoff_dt, 'mm') <=3
group by TO_CHAR(opCase.writeoff_dt, 'mm');
Below the .Net code for the same ?
ResultsetFields fieldsEligible = new ResultsetFields(3);
fieldsEligible.DefineField(UiOpWriteoffDtlFields.OvrpymntCaseAdjstmntAm, 0, AggregateFunction.Sum);
fieldsEligible.DefineField(UiOpWriteoffDtlFields.OpCaseFeesAm, 1, AggregateFunction.Sum);
fieldsEligible.DefineField(UiOpCaseFields.WriteoffDt, 2);
//fieldsEligible.DefineField(UiOpCaseFields.WriteoffDt.ToDateTime().Month, 2);
//fieldsEligible.DefineField(UiOpCaseFields.WriteoffDt, 3);
//ResultsetFields result = new ResultsetFields(1);
//result.DefineField(UiOpCaseFields.WriteoffDt,0);
//result.
//fieldsEligible[2].ExpressionToApply.ToDateTime().Month;
GroupByCollection groupByEligible = new GroupByCollection();
groupByEligible.Add(UiOpWriteoffDtlFields.OvrpymntCaseAdjstmntAm);
groupByEligible.Add(UiOpWriteoffDtlFields.OpCaseFeesAm);
groupByEligible.Add(UiOpWriteoffDtlFields.OvrpymntCaseAdjstmntAm);
RelationCollection relEligible = new RelationCollection();
EntityRelation relUiOpWriteOffWithUiOpWriteOffDtl = new EntityRelation();
relUiOpWriteOffWithUiOpWriteOffDtl.AddEntityFieldPair(UiOpWriteoffDtlFields.OverpaymentWriteoffId, UiOpWriteoffFields.OverpaymentWriteoffId);
relUiOpWriteOffWithUiOpWriteOffDtl.HintForJoins = JoinHint.Inner;
relEligible.Add(relUiOpWriteOffWithUiOpWriteOffDtl);
EntityRelation relUiOpWriteOffWithUiOpCase = new EntityRelation();
relUiOpWriteOffWithUiOpCase.AddEntityFieldPair(UiOpCaseFields.OverpaymentCaseId, UiOpWriteoffDtlFields.OpCaseId);
relUiOpWriteOffWithUiOpCase.HintForJoins = JoinHint.Inner;
relEligible.Add(relUiOpWriteOffWithUiOpCase);
PredicateExpression predExp = new PredicateExpression();
predExp.Add(UiOpCaseFields.WriteoffDt >= DateUtil.GetFirstDayOfQuarter(batchDate));
predExp.Add(UiOpCaseFields.WriteoffDt <= DateUtil.GetLastDayOfQuarter(batchDate));
eligibleOpCases = TypedListDAO.GetMultiAsDataTable(fieldsEligible, 0, null, predExp, relEligible, true, groupByEligible, 0, 0);