Hello,
Dymamics 365 uses a query language called FetchXML to query records. These can be translated to SQL but, in Dynamics 365 (CRM) Online you do not have direct access to the database.
You can use the Fetch XML tool from the XrmToolBox ( https://www.xrmtoolbox.com/plugins/ ) to run FetchXml queries against your Dynamics 365 organization.
The records you see under 'Participating' records are Opportunities.
The system runs the following query for 'Actual':
<fetch distinct="false" no-lock="true" mapping="logical" page="1" count="250" returntotalrecordcount="true">
<entity name="opportunity">
<attribute name="name"/>
<attribute name="estimatedvalue"/>
<attribute name="statuscode"/>
<attribute name="estimatedclosedate"/>
<attribute name="opportunityid"/>
<attribute name="processid"/>
<attribute name="name"/>
<attribute name="estimatedvalue"/>
<attribute name="statuscode"/>
<attribute name="estimatedclosedate"/>
<link-entity name="workflow" to="processid" from="workflowid" link-type="outer" alias="processidworkflowworkflowid">
<attribute name="versionnumber"/>
</link-entity>
<attribute name="statecode"/>
<filter type="and">
<filter type="and">
<condition attribute="ownerid" operator="eq" value="{00000000-0000-0000-0000-000000000000}"/>
<condition attribute="actualclosedate" operator="between">
<value>2017-12-31T00:00:00</value>
<value>2018-03-31T00:00:00</value>
</condition>
<condition attribute="statecode" operator="eq" value="1"/>
</filter>
</filter>
<order attribute="name" descending="false"/>
</entity>
</fetch>
Please note that you need to replace the underlined values. Replace the GUID with the record ID of the user who owns the goal, and the start and end dates with the start and end dates of your goal.
This would be the SQL equivalent:
SELECT
[name],
[estimatedvalue],
[statuscode],
[estimatedclosedate],
[opportunityid],
[processid],
[estimatedvalue],
[statuscode],
[estimatedclosedate],
[statecode],
[processidworkflowworkflowid].[versionnumber]
FROM
[FilteredOpportunity]
LEFT OUTER JOIN [workflow] AS [processidworkflowworkflowid]
ON [processidworkflowworkflowid].[workflowid] = [FilteredOpportunity].[processid]
WHERE
[FilteredOpportunity].[ownerid] = '00000000-0000-0000-0000-000000000000'
AND [FilteredOpportunity].[statecode] = 1
AND [FilteredOpportunity].[actualclosedate] BETWEEN '2017-12-31' AND '2018-03-31'
The system runs this query for 'In Progress':
<fetch distinct="false" no-lock="true" mapping="logical" page="1" count="250" returntotalrecordcount="true">
<entity name="opportunity">
<attribute name="name"/>
<attribute name="estimatedvalue"/>
<attribute name="statuscode"/>
<attribute name="estimatedclosedate"/>
<attribute name="opportunityid"/>
<attribute name="processid"/>
<attribute name="name"/>
<attribute name="estimatedvalue"/>
<attribute name="statuscode"/>
<attribute name="estimatedclosedate"/>
<link-entity name="workflow" to="processid" from="workflowid" link-type="outer" alias="processidworkflowworkflowid">
<attribute name="versionnumber"/>
</link-entity>
<attribute name="statecode"/>
<filter type="and">
<filter type="and">
<condition attribute="ownerid" operator="eq" value="{00000000-0000-0000-0000-000000000000}"/>
<condition attribute="estimatedclosedate" operator="between">
<value>2017-12-31T00:00:00</value>
<value>2018-03-31T00:00:00</value>
</condition>
<condition attribute="statecode" operator="eq" value="0"/>
</filter>
</filter>
<order attribute="name" descending="false"/>
</entity>
</fetch>
And the SQL equivalent
SELECT
[name],
[estimatedvalue],
[statuscode],
[estimatedclosedate],
[opportunityid],
[processid],
[estimatedvalue],
[statuscode],
[estimatedclosedate],
[statecode],
[processidworkflowworkflowid].[versionnumber]
FROM
[FilteredOpportunity]
LEFT OUTER JOIN [workflow] AS [processidworkflowworkflowid]
ON [processidworkflowworkflowid].[workflowid] = [FilteredOpportunity].[processid]
WHERE
[FilteredOpportunity].[ownerid] = '00000000-0000-0000-0000-000000000000'
AND [FilteredOpportunity].[statecode] = 0
AND [FilteredOpportunity].[actualclosedate] BETWEEN '2017-12-31' AND '2018-03-31'
Hope this helps you get started. If you have any other questions, please let me know!
If you found my answer helpful, please help the community by marking it as verified :-)