query

  • Thread starter Thread starter subs
  • Start date Start date
S

subs

SELECT X.*
FROM PPG AS X INNER JOIN PPG AS Y ON (X.BL<>Y.BL) AND
(X.Ship_Date=Y.Ship_Date) AND (X.Consignee=Y.Consignee) AND
(X.Ozip=Y.Ozip) AND (X.Dzip=Y.Dzip);

This query will group records which has same ozip,dzip,shipdate but
different bl. But i want to filter andsee only those groups which has
atleast one zip from two sets of ozips.

Two sets of ozips are
07034,450089
1245,4568

For example the group should have either 07034 or 450089 from the
first set AND either 1245 or 4568 from the second set. I donot want
to see those groups of records which have ozips from one set only.

What would be the query/ Pls help Thanks
 
Try this --
SELECT X.*
FROM PPG AS X INNER JOIN PPG AS Y ON (X.BL<>Y.BL) AND
(X.Ship_Date=Y.Ship_Date) AND (X.Consignee=Y.Consignee) AND
(X.Dzip=Y.Dzip) AND ((X.Ozip = 07034 AND Y.Ozip = 1245) OR (X.Ozip = 07034
AND Y.Ozip = 4568) OR (X.Ozip = 450089 AND Y.Ozip = 1245) OR (X.Ozip = 450089
AND Y.Ozip = 4568));
 
Back
Top