I am a beginner concerning SOQL, I hope you can help me. I would like to combine these two queries:
Query 1:
SELECT Id, Category__c, Segment__c
FROM Account
WHERE (Category__c = 'Prospect' AND Segment__c = 'High') OR (Category__c = 'Referrer' AND Segment__c = 'High')
Query 2:
SELECT Account_vod__c, WEEK_IN_YEAR(Call_Date_vod__c), CALENDAR_YEAR(Call_Date_vod__c)
FROM Call2_vod__c
WHERE Call_Date_vod__c = LAST_N_WEEKS:7
GROUP BY Account_vod__c, Call_Date_vod__c
Where the id of Account should equal the Account_vod__c value from Call2_vod__c.
When I combine these, I get something as:
Combined Query:
SELECT Id, Category__c, Segment__c
FROM Account
WHERE id in (select Account_vod__c from Call2_vod__c where Call_Date_vod__c = LAST_N_WEEKS:7) AND ((Category__c = 'Prospect' AND Segment__c = 'High') OR (Category__c = 'Referrer' AND Segment__c = 'High'))
But now I am missing the Week and Year values:
WEEK_IN_YEAR(Call_Date_vod__c), CALENDAR_YEAR(Call_Date_vod__c)
and this part: GROUP BY Account_vod__c, Call_Date_vod__c
How Can I combine these queries and display the right week and calendar data?
Thanks!