You need to sign in to do that
Don't have an account?

What is the use of COUNT_DISTINCT function ?
Hi,
Unable to understand the use COUNT_DISTINCT function.Can anybody explain with an example
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Hi,
Unable to understand the use COUNT_DISTINCT function.Can anybody explain with an example
first i will say the example :
Lead l1 = new Lead(Name = 'l1', Company = 'Salesforce');
Lead l2 = new Lead(Name = 'l1', Company = 'IBM');
Lead l3 = new Lead(Name = 'l1', Company = 'Microsoft');
Lead l4 = new Lead(Name = 'l1', Company = 'Salesforce');
Consider you have these records in salesforce lead object, now i want count of distinct company names.
I will write the query as
This will lead output as 3
So COUNT_DISTINCT(field) returns the number of distinct non-null field values matching the query criteria.
this might be helpful
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_agg_functions.htm