You need to sign in to do that
Don't have an account?
Mike DeMille
SOQL Query - Need Help!
I don't know if this can be done, but I'm trying to get a count of tasks and events related to either an account or contact under an account.
I was hoping something like:
SELECT Id
FROM Account
(SELECT COUNT(Id)
FROM TASK)
I'm basically trying to see how many tasks and events are related to an account (through account or account contacts). My query doesn't recognize 'TASK' in this query, plus I am missing many other things like how to query for events also.
Can anyone help point me in the right direction? I'm just running this from workbench
I was hoping something like:
SELECT Id
FROM Account
(SELECT COUNT(Id)
FROM TASK)
I'm basically trying to see how many tasks and events are related to an account (through account or account contacts). My query doesn't recognize 'TASK' in this query, plus I am missing many other things like how to query for events also.
Can anyone help point me in the right direction? I'm just running this from workbench
select whatid,what.name, count(id) from task group by whatid,what.name
select whatid,what.name, count(id) from event group by whatid,what.name
All Answers
select whatid,what.name, count(id) from task group by whatid,what.name
select whatid,what.name, count(id) from event group by whatid,what.name
SELECT Id , (SELECT
COUNT(Id)FROM TASKS) // NOT CORRECTFROM Account
But the following request is correct:
SELECT Id , (SELECT Id FROM TASKS)
FROM Account
Notice the "S" at the end of TASK.
That was your first idea but it is not allowed in SOQL.