I have XML data stored in SQL Server database in one column.
<data>
<row>
<element name="product">Piston</element>
<element name="number">1.2</element>
</row>
<row>
<element name="product">Piston Ring</element>
<element name="number">2</element>
</row>
<row>
<element name="product">Piston</element>
<element name="number">1.5</element>
</row>
</data>
Is there a way I can get result in following format?
------------------------------
Product | Count
------------------------------
Piston | 2
Piston Ring| 1
------------------------------
I tried with Xpath which gives me count of anything, but not sure if I can group by product and then get a count.
I'm looking for something like (In SQL Query)
SELECT Product, Count(Product) FROM ABC
GROUP BY Product