Say I have the following 3 peices of example data, I'm looking to be
able to get the distinct node count from each fragment, does xquery
have anything like this? I found distinct-value, but that looks at the
value of the element also. I have placed the counts after each
fragment that I'm looking for... (<profile> always exists so not having
that in the count is fine, I have included it in the following counts)
Each fragment represents one row.
I'm looking for something like (SQL 2005)
Select xmlData.query('count ** magic **') from Table
<profile>
<hairColor>Brown</hairColor>
<hairColor>None</hairColor>
<height>5'9''</height>
<height>6'6''</height>
<sex>M</sex>
</profile>
-- count: 4
<profile>
<birthDate>9-99-99</birthDate>
<height>6'6''</height>
<height>5'9''</height>
<sex>M</sex>
</profile>
-- count: 4
<profile>
<birthDate />
<sex>F</sex>
<sex>M</sex>
</profile>
-- count: 3
Thanks for the help,
JBSelect xmlData.query('count(distinct-values(for $a in /profile/* return
local-name($a)))') from Table|||Awesome, thanks alot!
No comments:
Post a Comment