SELECT
element,
qualifier,
scope_note,
count(*)
FROM metadatavalue
JOIN metadatafieldregistry
ON metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id
GROUP BY
metadatafieldregistry.element,
metadatafieldregistry.qualifier,
metadatafieldregistry.scope_note
ORDER BY ELEMENT asc
if you're not concerned about the counts, you could simplify things by using a
SELECT DISTINCT
query and removing the GROUP BY
block.