function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ramana VRamana V 

SOQL Query to retrieve last year records

Hi All,
I have two object. Student__c (Child) and College__c (Parent).
I want to fetch records of college which are not in Student. So, I have written SOQL like this.

List<college__c> colList = [select id, name from college where ID NOT IN (select college__c from student)];

Now, I have to retrieve colleges from last year (2019) and department equals to Physics. If I am moving to 2021 then I want to see only 2020 records.

How can I modify above SOQL for my requirement.

Please help me.

Thanks in Advance.

Regards,

Ramana V

SOQL Query to retrieve last year records
Bhupinder Walia 10Bhupinder Walia 10
List<college__c> colList =select id, name from account where ID NOT IN (select person_Account__c from lead) AND CreatedDate = LAST_YEAR AND department = 'Physics'
Ramana VRamana V

Hi Bhupinder,
Thanks for your reply

I have to fetch account ids in opportunity where createddate = last_year and department__c ='Physics' and I need to add this condition to my existing SOQL which stated above

 

Mark ValenzuelaMark Valenzuela
A huge thanks. I always have some troubles with lists and collection. Even do not know why. Need to fix my project (https://homework-writer.com) ASAP!