• Kunal Alandkar 9
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi everyone,
How to filter a SOQL query by two or more fields (key fields)? For example let's say I have an object with three fields: Person (String), Year (String) and Income (Number). Person and Year are key fields. And there are four records in the object:

Person                    Year                       Income
'Jhon'                      '2016'                      1000
'Jhon'                      '2017'                      950
'Mike'                      '2016'                       1100
'Mike'                      '2017'                       900

Then I want to retrieve data about Jhon's income in 2016 and Mike's income in 2017
In some SQL implementations I can do it in such way:
Select Person, Year, Income From MyObject Where (Person, Year) In (('Jhon', '2016'), ('Mike', '2017'))
What about SOQL? I was told that it won't accept such a query. Is there any means? Or I have to use "And" filter separately for every field and then use a loop?