function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
venkateshyadav1243venkateshyadav1243 

soql distinct values

hi i want to get distinct values from the list of values

 

i have a filed called brandcategory in this i have some data from this i want get distinct values in my visualforce page

example: in my filed i have this data

1

1

2

2

3

4

5

and i have to show result in my vf like this

1;2;3;4;5



 

how can we achive this

 

can any one help me

thanks for advance to all

 

 

Ritesh AswaneyRitesh Aswaney

To do it in apex, simply add elements to a Set, which by virtue of being a collection of unique elements will only admit elements to be added once.

 

You can then iterate over the set to get the unique elements.

 

To do it in SOQL use HAVING with Group By (http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_having.htm)