MarkMpn / Sql4Cds

SQL 4 CDS core engine and XrmToolbox tool
MIT License
74 stars 22 forks source link

【Bug?】"An item with the same key has already been added" when applying UNION ALL inside the CROSS APPLY clause #348

Closed hiroyuki0415 closed 1 year ago

hiroyuki0415 commented 1 year ago
SELECT b.businessunitid,
       child.guid
FROM   businessunit AS b CROSS APPLY (SELECT t.teamid AS guid
                                      FROM   team AS t
                                      WHERE  t.businessunitid = b.businessunitid
                                      UNION ALL
                                      SELECT s.systemuserid AS guid
                                      FROM   systemuser AS s
                                      WHERE  s.businessunitid = b.businessunitid) AS child;

When I run this SQL I get the following error:

An item with the same key has already been added

Thanks in advance for your support.