Cita:
Me canso y no me dais la solución, a ver si os apuráis.
Saludos
|
A pedido de Caral, aca va un aporte
Se me ocurre crear un view
Código SQL
[-]
CREATE VIEW CLIENTES_VIEW(
IDCLIENTE,
MES,
CONDICION,
IMPORTE)
AS
select c.idcliente, c.mes, c.condicion, c.importe
from clientes c
where c.condicion is not null
union
select c.idcliente, c.mes
, (select c2.condicion from clientes c2 where c2.condicion is not null and c2.idcliente=c.idcliente and c2.mes=c.mes)
, c.importe
from clientes c
where c.condicion is null
;
y despues hacer el select sobre el view
Código SQL
[-]
select idcliente, mes, condicion, sum(importe)
from clientes_view
group by idcliente, mes, condicion
order by idcliente, mes
Saludos