1. aggregation시 조건부 sum을 하는 방법입니다.

https://stackoverflow.com/questions/41218321/grouping-and-sum-with-conditions

 

ConditionalOperators.Cond cond = when(Criteria.where("status").is("PRESENT")).then(1)
                .otherwise(when(Criteria.where("status").is("ABSENT")).then(2)
                .otherwise(100));
                
//ond operatorNbS = ConditionalOperators.when("scst").thenValueOf(1).otherwise(0);

Aggregation agg = newAggregation(
    match(Criteria.where("bid").is("build_1481711758"),
    project("bid") 
        .and("scst")                            
        .applyCondition(cond, field("nbE"))

 

2. aggregation시 substring을 이용한 조건부 sum을 하는 방법입니다.

https://recordsoflife.tistory.com/463

Posted by yongary
,