I'm looking to get the sum of two counts into one value/attribute in the XML returned.
Here is the simplified query as it returns now, with two different sum columns:
This returns:
<XMLTest Status="No Status Set" mainCount="691" subCount="300"/>
I'm looking for a way to return just one count representing the sum of mainCount and subCount, with the resulting XML looking like this:
<XMLTest Status="No Status Set" totalCount="991"/>
I have tried adding a sum into the select statement which would combine mainCount and subCount. This is not working, because SQL seems to need an explicit field name, rather than an alias.
Does anyone have any suggestions to help me out?
Thanks,
Kate
[small]Yeah, it's a non-nutritive cereal varnish. It's semi-permeable. It's not osmotic.[/small]
[small]What it does is it coats and seals the flake, prevents the milk from penetrating it."[/small]
Here is the simplified query as it returns now, with two different sum columns:
Code:
select 1 as TAG,
null as PARENT,
'No Status Set' as [XMLTest!1!Status],
count(*) as [XMLTest!1!mainCount],
(select count(*) from Table2 aa) as [XMLTest!1!subCount]
from Table1 a
for xml explicit
This returns:
<XMLTest Status="No Status Set" mainCount="691" subCount="300"/>
I'm looking for a way to return just one count representing the sum of mainCount and subCount, with the resulting XML looking like this:
<XMLTest Status="No Status Set" totalCount="991"/>
I have tried adding a sum into the select statement which would combine mainCount and subCount. This is not working, because SQL seems to need an explicit field name, rather than an alias.
Does anyone have any suggestions to help me out?
Thanks,
Kate
[small]Yeah, it's a non-nutritive cereal varnish. It's semi-permeable. It's not osmotic.[/small]
[small]What it does is it coats and seals the flake, prevents the milk from penetrating it."[/small]