質問

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