Reputation: 7299
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
Upvotes: 0
Views: 1370
Reputation: 841
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.
Upvotes: 2
Reputation: 3748
When using group by you could use HAVING clause to filter the aggregate function by criteria.
Upvotes: 0