我有以下用于在Business Intelligent Development Studio中创建报告的FetchXML查询。
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="incident">
<attribute name="ticketnumber" />
<attribute name="createdon" />
<attribute name="statuscode" />
<attribute name="incidentid" />
<attribute name="caseorigincode" />
<attribute name="new_statussla" />
<attribute name="ownerid" />
<attribute name="new_caseaging" />
<attribute name="casetypecode" />
<order attribute="ticketnumber" descending="false" />
<filter type="and">
<condition attribute="createdon" operator="on-or-after" value="@Startdate" />
<condition attribute="createdon" operator="on-or-before" value="@Enddate" />
<condition attribute="caseorigincode" operator="ne" value="3" />
</filter>
<link-entity name="systemuser" from="systemuserid" to="owninguser" visible="false" link-type="outer" alias="a_cf39b8fda77b421483a1af5e511c39ca">
<attribute name="new_region" />
<attribute name="businessunitid" />
</link-entity>
</entity>
</fetch>
我将此查询转换为SQL查询,如下所示。
SELECT a.ticketnumber, a.createdon, a.statuscode,
a.incidentid, a.caseorigincode, a.new_statussla,
a.ownerid, a.new_caseaging, a.casetypecode,
b.new_region, b.businessunitid
FROM FilteredIncident a, FilteredSystemUser b
WHERE a.ownerid = b.systemuserid
AND createdon >= @StartDate
AND creaedon <= @EndDate
AND caseorigincode != '3'
我的问题,我的SQL查询是否正确?虽然我可以执行它。
答案 0 :(得分:2)
出于需要,我刚刚创建了这个。在GitHub免费FetchXML to SQL Convertor!
正在进行的工作,但会提供可用的输出。试试吧! https://github.com/abtevrythng/FetchXML-to-SQL
这是fetchXML的生成输出:
SELECT incident.ticketnumber, incident.createdon, incident.statuscode, incident.incidentid, incident.caseorigincode, incident.new_statussla, incident.ownerid, incident.new_caseaging, incident.casetypecode, systemuser.new_region, systemuser.businessunitid
FROM incident
LEFT OUTER JOIN systemuser ON incident.systemuserid = systemuser.owninguser
WHERE incident.createdon TBD '@Startdate' AND incident.createdon TBD '@Enddate' AND incident.caseorigincode != '3'