Activity Forums Salesforce® Discussions How can we compare the multiple record fetch from soql query to each other?

  • How can we compare the multiple record fetch from soql query to each other?

    Posted by Mohit on August 16, 2016 at 2:41 pm

    Hi All,

    How can we compare the multiple record fetch from soql query to each other?

    I am in situation in which I want that result obtain from different SOQL query can be compare to one another.

    Please give suggestion

    Radhakrishna replied 7 years ago 3 Members · 2 Replies
  • 2 Replies
  • Surbhi

    Member
    August 26, 2016 at 2:29 pm

    Hi Mohit,

    You can use aggregate functions here. Use field in Group By for criteria of comparison.

    Thanks

  • Radhakrishna

    Member
    March 27, 2017 at 5:38 am

    Hello Mohit,

    Salesforce does not allow direct field to field comparison in SOQL query.

    To achieve this you may create a formula field that will compare fields and return a value (like true or false) which you may use in a WHERE clause.

    So for the above query, you could create a formula field on User object with return type Text e.g. NameCompare, with the formula

    IF(User.FirstName != User.LastName, 'true', 'false')

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos