Group by a result of a xml query

OESlover

New Member
I have table with a XML column (called MetaData) which looks like this:\[code\]<props> <prop name="bytes" value="http://stackoverflow.com/questions/12599885/194" /> <prop name="error" value="http://stackoverflow.com/questions/12599885/File is a text file" /> <prop name="mime-type" value="http://stackoverflow.com/questions/12599885/text/plain" /></props>\[/code\]Now I have some differnt errors which I can select with this here:\[code\]SELECT MetaData.value('(/props/prop[@name="error"]/@value)[1]', 'varchar(50)') Error, MetaData.value('(/props/prop[@name="mime-type"]/@value)[1]', 'varchar(50)') MimeType, *FROM sourceWHERE MetaData.exist('/props/prop[@name="error"]') = 1\[/code\]Now I would like to count how often a error accours:\[code\]SELECT MetaData.value('(/props/prop[@name="error"]/@value)[1]', 'varchar(50)') Error, COUNT(*) CountFROM sourceWHERE MetaData.exist('/props/prop[@name="error"]') = 1GROUP BY Error\[/code\]But I get the error message:\[quote\] Meldung 207, Ebene 16, Status 1, Zeile 5
Ung
 
Back
Top