query

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
 
K

KARL DEWEY

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));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Pls correct this query 4
query with conditions 1
Query Help 2

Top