API LIBRARY
Collapse Sidebar Menu
Expand Drawer

Select Distinct

Using the OData GroupBy feature, one can query for distinct values for a given field. For example, if you need to find unique list of Cities for given state. Or distinct combination of City+PostalCode. You can apply additional filters to this query just like regular OData queries.

Append this to your query: (notice the double parenthesis - thats the OData standard).

Single Distinct field:        eg. &$apply=groupby((PostalCity))
Multiple distinct fields:   eg. &$apply=groupby((PostalCity,  PostalCode))
*Only top 10,000 records will be retrieved.

Examples

Code Example

Select Distinct Cities:

{{api_url}}/odata/Property?$filter=StateOrProvince eq 'CA'&$apply=groupby((PostalCity))

Result

{
    "@odata.context": "https://api-prod.corelogic.com/trestle/odata/$metadata#Property/CoreLogic.DataStandard.RESO.DD.Property",
    "value": [
        {
            "PostalCity": "Alhambra"
        },
        {
            "PostalCity": "Alleghany"
        },
        {
            "PostalCity": "Alturas"
        },
        {
            "PostalCity": "Anderson"
        },
        {
            "PostalCity": "Angelus Oaks"
        },
        {
            "PostalCity": "Apple Valley"
        },
        {
            "PostalCity": "Arboga"
        },
        {
            "PostalCity": "Arbuckle"
        },
        {
            "PostalCity": "Arrow Bear"
        },
        {
            "PostalCity": "Auburn"
        },
        {
            "PostalCity": "Bangor"
        },
        {
            "PostalCity": "Beaumont"
        },
        {
            "PostalCity": "Berry Creek"
        },
        {
            "PostalCity": "Big Bear City"
        },
        {
            "PostalCity": "Big Bear Lake"
        }]
}

Code Example

Select Distinct Cities and PostCodes:

{{api_url}}/odata/Property?$filter=StateOrProvince eq 'CA'&$apply=groupby((PostalCity,  PostalCode))

Result

{
    "@odata.context": "https://api-prod.corelogic.com/trestle/odata/$metadata#Property/CoreLogic.DataStandard.RESO.DD.Property",
    "value": [
 {
            "PostalCity": "Sacramento",
            "PostalCode": "95833"
        },
        {
            "PostalCity": "Sacramento",
            "PostalCode": "95838"
        },
        {
            "PostalCity": "Sacramento",
            "PostalCode": "95842"
        },
        {
            "PostalCity": "San Bernardino",
            "PostalCode": "92407"
        },
        {
            "PostalCity": "San Diego",
            "PostalCode": "92054"
        },
        {
            "PostalCity": "San Jose",
            "PostalCode": "95123"
        }]
}