I'm getting error 'not a single-group group function. Following the documentation i have a group by with the column that is not agreggated in the select statement, but is not working.
SELECT
XMLELEMENT(
"CLASIFICATION",
XMLATTRIBUTES(vm.value As "name"),
XMLAgg(
XMLElement(
"GRUP",
XMLATTRIBUTES(c.description_group As "name"),
XMLAgg(
XMLElement(
"CLAUSE",
XMLATTRIBUTES(cla.description_clause As "name")
)
)
)
)
)
FROM
dbo.clause cla,
dbo.clause_group c,
dbo.values vm
where
vm.table_name = 'CLAUSE_TYPES'
and c.code = vm.code
and cla.id_group = c.id_group
GROUP BY
vm.value