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
Subha Ayyappan 7Subha Ayyappan 7 

SOQL to get the records created in a day, week and month

Hi all,
I want to get the records of an object created in a day, week and month all in the same query. Is it possible?
AshlekhAshlekh
Hi,

You have query the record from a specific date range. And the by code you can create a MAP and maintain the data in MAP.

You can do only this if you want to use only single query. Otherwise you have to query with differenct date criteria.

-Thanks
Ashlekh Gera
Subha Ayyappan 7Subha Ayyappan 7
Thanks for your response. I am new to salesforce.
Below are my 3 queries which i want to make it one because i do not want to take the physician name 3 times.
Select Encountered_Physician_Id__r.User__r.FirstName,count(Encounter__c.Id) from Encounter__c where CreatedDate = today Group By Encountered_Physician_Id__r.User__r.FirstName
Select Encountered_Physician_Id__r.User__r.FirstName,count(Encounter__c.Id) from Encounter__c where CreatedDate = Last_week Group By Encountered_Physician_Id__r.User__r.FirstName
Select Encountered_Physician_Id__r.User__r.FirstName,count(Encounter__c.Id) from Encounter__c where CreatedDate = Last_month Group By Encountered_Physician_Id__r.User__r.FirstName
Is it possible? Please help.