Ver Mensaje Individual
  #6  
Antiguo 07-09-2015
synapsevzla synapsevzla is offline
Registrado
NULL
 
Registrado: sep 2015
Posts: 5
Reputación: 0
synapsevzla Va por buen camino
osea que tendria que ser algo como esto?

Código SQL [-]
CREATE OR ALTER VIEW VIEW_LIBROVTAIVA2015(
    CORRELATIVO,
    CORRELATIVO_CODIGO,
    DOCUMENTO,
    TIPO_DOCUMENTO,
    CLIENTE_CODIGO,
    CLIENTE_NOMBRE,
    CLIENTE_RIF,
    FECHA_EMISION,
    HORA_EMISION,
    TOTAL_OPERACION,
    TOTAL_BASE_IMPONIBLE,
    TOTAL_IMPUESTO_FISCAL,
    TOTAL_EXENTO,
    CORRELATIVO_PRINCIPAL,
    TOTAL_NETO_01,
    TOTAL_IMPUESTO_01,
    PORC_IMPUESTO_01,
    IMPUESTO_IVA_CODIGO_01,
    CORRELATIVO_PRINCIPAL1,
    TOTAL_NETO_03,
    TOTAL_IMPUESTO_03,
    PORC_IMPUESTO_03,
    IMPUESTO_IVA_CODIGO_03,
    ORDEN_DE_COMPRA)
AS
select 
    ventas.correlativo,
    ventas.correlativo_codigo,
    ventas.documento,
    ventas.tipo_documento,
   if (ventas.tipo_documento='DEV', -1*ventas.total_operacion, ventas.total_operacion) as ventas.total_operacion,
    ventas.cliente_codigo,
    ventas.cliente_nombre,
    ventas.cliente_rif,
    ventas.fecha_emision,
    ventas.hora_emision,
    ventas.total_operacion,
    ventas.total_base_imponible,
    ventas.total_impuesto_fiscal,
    ventas.total_exento,
    view_compiladoiva01.correlativo_principal,
    view_compiladoiva01.total_neto_01,
    view_compiladoiva01.total_impuesto_01,
    view_compiladoiva01.porc_impuesto_01,
    view_compiladoiva01.impuesto_iva_codigo_01,
    view_compiladoiva03.correlativo_principal,
    view_compiladoiva03.total_neto_03,
    view_compiladoiva03.total_impuesto_03,
    view_compiladoiva03.porc_impuesto_03,
    view_compiladoiva03.impuesto_iva_codigo_03,
    ventas.orden_de_compra
from ventas
   inner join view_compiladoiva01 on (ventas.correlativo = view_compiladoiva01.correlativo_principal)
   inner join view_compiladoiva03 on (ventas.correlativo = view_compiladoiva03.correlativo_principal)

Si fuerabn mas valores que al conicidir con DEV tubiesen que cambiar a negativo como seria y si la condicion Fuese no solo DEV si no tambien NC o tra condicion como podria lograrlo?

Nota: trate de crearlo asi y no me manda error el ibexpert la linea que resalto en rojo me la muestra como error.

y los valores que tendrian que cambiar a negativo cuando aparesca la condicion DEV o NC serian los resaltados en azul
Responder Con Cita