Cita:
Empezado por abraham
algien me puede ayudar con el sql else
|
Bueno, como ya te había comentado, puedes usar un procedimiento almacenado, un ejemplo es el siguiente:
Código SQL
[-]
CREATE PROCEDURE Retorna_Valor (
TIPO INTEGER,
VALOR NUMERIC(15,2),
PORCENTAJE NUMERIC(15,2))
RETURNS (
TOTAL NUMERIC(15,2))
AS
begin
if (:tipo is not null) then
begin
if (:tipo = 0) then
total = :porcentaje;
else
if (:tipo = 1) then
total = :valor;
end
suspend;
end
Para usarlo bastaría con incluirlo en una consulta sql, como la siguiente, por ejemplo:
Código SQL
[-]
select (select total from Retorna_Valor(tipo, Valor, porcentaje)) as Retorno from Tabla_que_contiene_dichos_valores
Espero me haya hecho entender y que te sirva de algo.