SQL Server - concatener consultas

 
Vista:

concatener consultas

Publicado por Danieltron (67 intervenciones) el 30/10/2009 13:29:27
Hola maestros

necesito de su ayuda estoy realizando una consulta para armar el cuerpo de un archivo xml

pero necesito que me entregue el resultado unido y la siguiente consulta me los muestra separados,

select ltrim(rtrim('<dataset seriesName=''CC1'' color=''1D8BD1'' anchorBorderColor=''1D8BD1'' anchorBgColor=''1D8BD1''>'))
if (select ltrim(rtrim('<set value=''')) + (select ltrim(rtrim(cast(cant as char))) from fuente_hora where fte = 'CC1' and hora = '00') + (select ltrim(rtrim('''/>')))) is NULL
begin select ltrim(rtrim('<set value=''0''/>')) end
else
begin (select ltrim(rtrim('<set value=''')) + (select ltrim(rtrim(cast(cant as char))) from fuente_hora where fte = 'CC1' and hora = '00') + (select ltrim(rtrim('''/>')))) end

el resultado que me muestra es:

<dataset seriesName='CC1' color='1D8BD1' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'>

<set value='271'/>

y deberia ser

mostralo como como la siguiente consulta

select ltrim(rtrim('<category label=''23'' />'))
union all
select ltrim(rtrim('<category label=''24'' />'))
union all
select ltrim(rtrim(ltrim(rtrim('</categories>'))))

el cual es resultado es

<category label='23' />
<category label='24' />
</categories>

si se fijan me los entrego esas tres lineas en un solo resultado, esta consulta es para armar el cuerpo de un archivo xml como este, que es para generar un grafico

<chart caption='' numberScaleValue='1000,1000,1000' numberScaleUnit='ml,M,B' decimals="0" numberPrefix="Q" lineThickness='1' showValues='0' formatNumberScale='Q' anchorRadius='2' divLineAlpha='20' divLineColor='494947' divLineIsDashed='1' showAlternateHGridColor='1' alternateHGridAlpha='5' alternateHGridColor='494947' shadowAlpha='40' labelStep="1" numvdivlines='10' chartRightMargin="35" bgColor='7A7A7A,BCBCBC' bgAngle='270' bgAlpha='50,40' baseFontColor ='000000'
xAxisName='Hora' yAxisName='Cantidad CDR' >

<categories >
<category label='01 ' />
<category label='02' />
<category label='03' />
<category label='04' />
<category label='05' />
<category label='06' />
<category label='07' />

</categories>
<dataset seriesName='CC1' color='1D8BD1' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'>

<set value='100' />
<set value='20' />
<set value='40' />
<set value='48' />
<set value='59' />
<set value='60' />
<set value='65' showValue='0' anchorRadius='6' anchorSides='4' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1' />
<set value='70' />
</dataset>

por favor alguna idea, la tabla contiene 3 columnas fuente, cantidad y hora.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder