Respuesta: mostrar ultimo valor de cada columna amix, hice algo asi: me sale de resultado la primera fila, mmmm donde puedo estar fallando?
SELECT T0.ano,T0.meta,T0.mes,T1.m1,T2.m2, T3.m3, T4.m4, T5.m5 FROM #rm T0
INNER JOIN (
SELECT ano,meta,mes,m1, max(x) x FROM #rm T1 WHERE m1 >= 0 GROUP BY ano,meta,mes,m1
) T1 ON T0.ano = T1.ano AND T0.meta = T1.meta AND T0.mes = T1.mes AND T0.x = T1.x
INNER JOIN (
SELECT ano,meta,mes,m2,max(x) x FROM #rm T2 WHERE m2 >= 0 GROUP BY ano,meta,mes,m2
) T2 ON T0.ano = T2.ano AND T0.meta = T2.meta AND T0.mes = T2.mes AND T0.x = T2.x
INNER JOIN (
SELECT ano,meta,mes,m3,max(x) x FROM #rm T3 WHERE m3 >= 0 GROUP BY ano,meta,mes,m3
) T3 ON T0.ano = T3.ano AND T0.meta = T3.meta AND T0.mes = T3.mes AND T0.x = T3.x
INNER JOIN (
SELECT ano,meta,mes,m4,max(x) x FROM #rm T4 WHERE m4 >= 0 GROUP BY ano,meta,mes,m4
) T4 ON T0.ano = T4.ano AND T0.meta = T4.meta AND T0.mes = T4.mes AND T0.x = T4.x
INNER JOIN (
SELECT ano,meta,mes,m5, max(x) x FROM #rm T5 WHERE m5 >= 0 GROUP BY ano,meta,mes,m5
) T5 ON T0.ano = T5.ano AND T0.meta = T5.meta AND T0.mes = T5.mes AND T0.x = T5.x
Última edición por hicolu; 05/11/2010 a las 18:24 |