The Silver Lining

Lessons & Learnings from a salesforce certified technical architect.

Posts Tagged ‘Distinct

SOQL ‘Distinct’ Keyword

with 16 comments

It doesn’t exist. Sad but true.

In SQL there is a clause that ensures a duplicate free result set is returned by any query you issue e.g. You want to retrieve a duplicate free list of first names from the table clients. The column holds the following values: Alice, Bob, Alice. In Oracle SQL you would use the following query (and it would return the names Alice and Bob each listed once)

SELECT DISTINCT firstname
FROM clients;

Unfortunately SOQL doesn’t have this capability although there is an Apex trick that can be employed as a work-around. Read the rest of this entry »

Advertisements

Written by Wes

June 28, 2009 at 3:54 pm

Posted in Apex, SOQL

Tagged with , , , , ,

%d bloggers like this: