Ver Mensaje Individual
  #4  
Antiguo 25-05-2007
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Pues el SQL local me parece que no cuenta con Coalesce o equivalente. Si ha de hacerse con SQL podrías intentar algo como

Código SQL [-]
select a,b,a+b
from tabla
where a is not null and b is not null

union all

select a,b,b
from tabla
where a is null and b is not null

union all

select a,b,a
from tabla
where a is not null and b is null

union all

select a,b,0
from tabla
where a is null and b is null

aunque lo veo bastante chapucero.

Podrías intentarlo del lado del cliente agregando un campo calculado al Table que uses, por ejemplo:

Código Delphi [-]
procedure TForm1.Table1CalcFields(DataSet: TDataSet);
begin
  DataSet['suma'] :=
    DataSet.FieldByName('a').AsInteger +
    DataSet.FieldByName('b').AsInteger;
end;

// Saludos
Responder Con Cita