Ver Mensaje Individual
  #9  
Antiguo 13-03-2008
Avatar de MaMu
MaMu MaMu is offline
Miembro
 
Registrado: abr 2006
Ubicación: Argentina
Posts: 863
Reputación: 21
MaMu Va por buen camino
Cita:
Empezado por keyboy Ver Mensaje
¿Y no has considerado la sugerencia que te hizo Neftali en el segundo mensaje?
Podrías tener un sólo DBGrid con una columna para cada fecha, haciendo muy fácil la comparación visual
y sin ener que recurrir a trucos raros.

Bye
Osea, que tendria que hacer un SELF-JOIN, porque deberia unir la tabla consigo misma.

tengo 2 tablas: CATEGORIAS y CAJA y consulto ambas en un año y otra en otro año (year(fecha)=xxxx), para compararlas

osea, ejecuto esto:


Código SQL [-]
select categoria, (select sum(debe) from caja t 
where t.categoria=a.categoria and year(t.fecha)=2008) as egreso,
(select sum(haber) from caja t where t.categoria=a.categoria and year(t.fecha)=2008)
 as ingreso from parapersonales a

y con la otra, lo mismo pero distinta fecha.
Lo que no me doy cuenta, donde meter el JOIN (sobre la misma tabla)


Código SQL [-]
select categoria, 
(select sum(debe) from caja t where t.categoria=a.categoria and year(t.fecha)=2008) as egreso,
(select sum(haber) from caja t where t.categoria=a.categoria and year(t.fecha)=2008) as ingreso 
from parapersonales a INNER JOIN (select categoria, 
(select sum(debe) from caja u where u.categoria=b.categoria and year(u.fecha)=2007) as egreso,
(select sum(haber) from caja u where u.categoria=b.categoria and year(u.fecha)=2007) as ingreso 
from parapersonales b)



......

__________________
Código Delphi [-]
 
try 
ProgramarMicro(80C52,'Intel',MnHex,True);
except
On Exception do
MicroChip.IsPresent(True);
end;

Última edición por MaMu fecha: 13-03-2008 a las 07:51:00.
Responder Con Cita