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

  • 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