Hello!
I have a query where I get all requirements in a branch.
Then I left join with another group or requirements and LEFT JOIN based on connector (deriveReqt).
Then I left join again with a group of system element and LEFT JOIN based on connector (satisfy).
So the setup is the following:
(system element) -- satisfy --> (system requirement) -- deriveReqt --> (stakeholder requirement)
Initially my output was two columns, one for ID of system requirements, and one for related stakeholder requirements which was grouped so the output would be something like this example:
System requirement ID | derived Stakeholder requirement ID
1 | 3
2 | 5, 8
3 | 6, 11
4 | 1, 7
But when I added a third column with system elements which satisfy the system requirements, the stakeholder column gets duplicated with the number of related system elements, for example:
System requirement ID | derived Stakeholder requirement ID | System element
1 | 3 | SE-1
2 | 5, 8, 5, 8 | SE-1, SE-2
3 | 6, 11 | SE-3
4 | 7, 7, 7 | SE-1, SE-2, SE-3
I can clearly see the connection between duplication of 'derived Stakeholder requirement ID' and the number of related 'System element'.
But I have no idea how I fix that.
The desired output would be:
System requirement ID | derived Stakeholder requirement ID | System element
1 | 3 | SE-1
2 | 5, 8 | SE-1, SE-2
3 | 6, 11 | SE-3
4 | 7 | SE-1, SE-2, SE-3
Full SQL:
SELECT SK_TABLE.CLASSGUID, SK_TABLE.CLASSTYPE,
SK_TABLE.SK_ID AS SK_ID,
SK_TABLE.SK_KAPITEL AS SK_KAPITEL,
SK_TABLE.SK_TEXT AS SK_TEXT,
COALESCE(GROUP_CONCAT(IK_TABLE.IK_ID, '; '), '---') AS IK_ID,
COALESCE(GROUP_CONCAT(SE_TABLE.NAME, '; '), '---') AS SE_NAME
FROM
(SELECT SK.ea_guid AS CLASSGUID, SK.Object_Type AS CLASSTYPE, SK.Object_ID AS SK_OID,
SK_ID.Value AS SK_ID, SK_PACKAGE.Name AS SK_KAPITEL, SK_TEXT.Notes AS SK_TEXT
FROM t_object SK
INNER JOIN t_objectproperties SK_ID ON SK_ID.Object_ID = SK.Object_ID AND SK_ID.Property = 'id'
INNER JOIN t_objectproperties SK_TEXT ON SK_TEXT.Object_ID = SK.Object_ID AND SK_TEXT.Property = 'text'
INNER JOIN t_package SK_PACKAGE ON SK_PACKAGE.Package_ID = SK.Package_ID
WHERE SK.Package_ID IN (#Branch='{4FD8BE48-EE95-44ae-ACCB-A7CE7851EB7C}'#)
AND SK.Stereotype = 'Systemkrav')
SK_TABLE
LEFT JOIN
(SELECT IK_ID.Value AS IK_ID, DERIVE.Start_Object_ID AS 'DERIVE_END'
FROM t_object IK
INNER JOIN t_objectproperties IK_ID ON IK_ID.Object_ID = IK.Object_ID AND IK_ID.Property = 'id'
INNER JOIN t_connector DERIVE ON DERIVE.End_Object_ID = IK.Object_ID AND DERIVE.Stereotype = 'deriveReqt'
WHERE IK.Package_ID IN (#Branch='{20273ECC-AB9C-43e3-8E6D-43E7DD60F3AC}'#)
AND IK.Stereotype = 'Intressentkrav')
IK_TABLE ON SK_TABLE.SK_OID = IK_TABLE.DERIVE_END
LEFT JOIN (
SELECT SE.Name AS NAME, SATISFY.End_Object_ID AS SATISFY_END
FROM t_object SE
INNER JOIN t_connector SATISFY ON SATISFY.Start_Object_ID = SE.Object_ID AND SATISFY.Stereotype = 'satisfy'
WHERE SE.Package_ID IN (#Branch='{95E5A654-A217-4122-B011-045E9F7A720D}'#)
AND SE.Stereotype = 'OperationalPerformer')
SE_TABLE ON SE_TABLE.SATISFY_END = SK_TABLE.SK_OID
GROUP BY SK_TABLE.CLASSGUID
ORDER BY LENGTH(SK_TABLE.SK_ID), SK_TABLE.SK_ID
Any pointers of how I would fix that would be appreciated!
When googling I found something using WITH, but IIRC SQL statements in Sparx EA MUST start with SELECT so didn't even bother to try it out.
Cheers!