Retrieve Records by comparing two Columns in Web API Query

Hi learners,

Till now, $filter can be applied for a field against a constant value. With this new feature $filter can be applied for a field against another field in scenarios like below

  • Get all contacts where First Name = Last Name
  • Get all Opportunities where Estimated Revenue >= Actual Revenue
  • Get all Cases Resolved post due date.

Supported Filters:

  1. Equal
  2. NotEqual
  3. GreaterThan
  4. GreaterEqual
  5. LessThan
  6. LessEqual

Example: To retrieve all contacts whose First Name = Last Name

Web API Query:

<Instance Web API>/contacts?$filter=firstname eq lastname
[ Note: This Web API expression works only for version 9.1.0000.19562 or later ]

fetch XML Query: