문제

Is there something equivalent to the excel countif function (http://www.techonthenet.com/excel/formulas/countif.php) in SOQL ?

This is especially important in group by queries.

In oracle I would use the case function together with the case function

sum(
    case
         when (condition is true) 
          then 1 else 0 
  end
) 

How do i perform the same in salesforce SOQL?

Thanks,

David

도움이 되었습니까?

해결책

This is one place where SOQL is not the equal of SQL. There is no CASE statement in SOQL, and there's really no way to accomplish a pivot here. We recently solved a similar problem by querying all rows and then accumulating the pivoted values using Apex, and then exposing that as an Apex web service so we could call the query on demand.

다른 팁

When using group by you could use HAVING clause to filter the aggregate function by criteria.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top