Вопрос

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