Subject | problems filtering in TIB_QUERY |
---|---|
Author | Adrián Deccico |
Post date | 2005-01-06T14:39:20Z |
Hi I have a TIB_QUERY with a union sql sentence that links three tables.
It works fine except when I try to use a filter. In this case the
TIB_QUERY only filter the records of the first table.
If I cut the union tables, to use only one table the filters works.
All the three table that I link are identical
select RI.ID,
'RI' AS TIPO_RET,
FECHA_RET,
RI.NRO,
CL.CUIT,
CI.CODE_COMP,
CL.RAZON_SOCIAL,
RI.TOTAL
from RI
LEFT JOIN FACTURAS FA ON (FA.ID_RI = RI.ID)
LEFT JOIN CLIENTES CL ON (FA.ID_CLIENTE = CL.ID_CLIENTES)
LEFT JOIN CONDICION_IVA CI ON (CL.ID_IVA = CI.ID_CONDICION)
WHERE RI.ID > 0 and FA.ID_RI > 0
UNION
select RT.ID,
'RT' AS TIPO_RET,
FECHA_RET,
RT.NRO,
CL.CUIT,
CI.CODE_COMP,
CL.RAZON_SOCIAL,
RT.TOTAL
from RT
LEFT JOIN FACTURAS FA ON (FA.ID_RT = RT.ID)
LEFT JOIN CLIENTES CL ON (FA.ID_CLIENTE = CL.ID_CLIENTES)
LEFT JOIN CONDICION_IVA CI ON (CL.ID_IVA = CI.ID_CONDICION)
WHERE RT.ID > 0 and FA.ID_RT > 0
UNION
SELECT RG.id,
'RG' AS TIPO_RET,
FECHA_RET,
RG.NRO,
CL.CUIT,
CI.CODE_COMP,
CL.RAZON_SOCIAL,
RG.TOTAL
FROM RG
LEFT JOIN FACTURAS FA ON (FA.ID_RG = RG.ID)
LEFT JOIN CLIENTES CL ON (FA.ID_CLIENTE = CL.ID_CLIENTES)
LEFT JOIN CONDICION_IVA CI ON (CL.ID_IVA = CI.ID_CONDICION)
WHERE RG.ID > 0 and FA.ID_RG > 0
;
--
atte
Adrián Deccico
It works fine except when I try to use a filter. In this case the
TIB_QUERY only filter the records of the first table.
If I cut the union tables, to use only one table the filters works.
All the three table that I link are identical
select RI.ID,
'RI' AS TIPO_RET,
FECHA_RET,
RI.NRO,
CL.CUIT,
CI.CODE_COMP,
CL.RAZON_SOCIAL,
RI.TOTAL
from RI
LEFT JOIN FACTURAS FA ON (FA.ID_RI = RI.ID)
LEFT JOIN CLIENTES CL ON (FA.ID_CLIENTE = CL.ID_CLIENTES)
LEFT JOIN CONDICION_IVA CI ON (CL.ID_IVA = CI.ID_CONDICION)
WHERE RI.ID > 0 and FA.ID_RI > 0
UNION
select RT.ID,
'RT' AS TIPO_RET,
FECHA_RET,
RT.NRO,
CL.CUIT,
CI.CODE_COMP,
CL.RAZON_SOCIAL,
RT.TOTAL
from RT
LEFT JOIN FACTURAS FA ON (FA.ID_RT = RT.ID)
LEFT JOIN CLIENTES CL ON (FA.ID_CLIENTE = CL.ID_CLIENTES)
LEFT JOIN CONDICION_IVA CI ON (CL.ID_IVA = CI.ID_CONDICION)
WHERE RT.ID > 0 and FA.ID_RT > 0
UNION
SELECT RG.id,
'RG' AS TIPO_RET,
FECHA_RET,
RG.NRO,
CL.CUIT,
CI.CODE_COMP,
CL.RAZON_SOCIAL,
RG.TOTAL
FROM RG
LEFT JOIN FACTURAS FA ON (FA.ID_RG = RG.ID)
LEFT JOIN CLIENTES CL ON (FA.ID_CLIENTE = CL.ID_CLIENTES)
LEFT JOIN CONDICION_IVA CI ON (CL.ID_IVA = CI.ID_CONDICION)
WHERE RG.ID > 0 and FA.ID_RG > 0
;
--
atte
Adrián Deccico