RE:Consulta de 6 campos
Publicado por
OScar leiton (1 intervención) el 26/10/2006 00:02:07
Hola Jesus, gracias por tu ayuda y disculpa la tardanza...., estuve intentando obtener la consulta, ya casi le llego, pero tengo algo mal en la setencia SQL, a ver si me puedes ayudar....
Esta es la sentencia SQL que estoy intentando:
select zfi2.record,Zfi2.Account,Zfi2.Vendorname,Zfi2.Code,
Zfi2.PstDate,Zfi2.Cur, Zfi2.Amount,Zfi2.DocDate,Zfi2.Reference,
min(case when ZFI2.Code = tabla.code and ZFI2.Amount = tabla.Amount and ZFI2.Cur = tabla.Cur and ZFI2.Reference = tabla.Reference and ZFI2.DocDate = tabla.DocDate then 'rel1' end)
min(case when ZFI2.Code = tabla.code and ZFI2.Account = tabla.Account and ZFI2.Cur = tabla.Cur and ZFI2.Reference = tabla.Reference and ZFI2.DocDate = tabla.DocDate then 'rel1' end),
min(case when ZFI2.Code = tabla.code and ZFI2.Account = Tabla.Account and ZFI2.Amount = tabla.Amount and ZFI2.Reference = tabla.Reference and ZFI2.DocDate = tabla.DocDate then 'rel1' end),
min(case when ZFI2.Code = tabla.code and ZFI2.Account = Tabla.Account and ZFI2.Amount = tabla.Amount and ZFI2.Cur = tabla.Cur and ZFI2.DocDate = tabla.DocDate then 'rel1' end),
min(case when ZFI2.Code = tabla.code and ZFI2.Account = Tabla.Account and ZFI2.Amount = tabla.Amount and ZFI2.Cur = tabla.Cur and ZFI2.Reference = tabla.Reference then 'rel1' end),
min(case when ZFI2.Account = Tabla.Account and ZFI2.Amount = tabla.Amount and ZFI2.Cur = tabla.Cur and ZFI2.Reference = tabla.Reference and ZFI2.DocDate = tabla.DocDate then 'rel1' end
from ZFI2, ZFI2 as tabla
Group By zfi2.record,Zfi2.Account,Zfi2.Vendorname,Zfi2.Code,
Zfi2.PstDate,Zfi2.Cur, Zfi2.Amount,Zfi2.DocDate,Zfi2.Reference
order by Zfi2.Reference desc
lo que deseo es obtener registros duplicados en los cuales coincidan al menos 5 campos,..., segun entiendo bien el minus, deberia filtrarme los datos según cada sentencia SELECT, es decir, los que obtengo en el primer select no deberia obtenerlos en el segundo select, y asi con la restantes sentencias Select.....pero sin embargo, con esta sentencia me extrae todos los registros de la tabla, no realiza el filtro.....NO ENTIENDO EN QUE FALLO...talvez tu le atines....de nuevo gracias por la ayuda