tnguyen315
MIS
Hello,
I created an access query with union. Everything is working fine now. But i would like to eliminate the duplicate records if more than one have the same Full street address.
Here is my query:
SELECT tableA.LOW_Right as From, tableA.UP_Right AS To, 1 AS Status, tableA.STREET AS FullStreetAddress
FROM tableA
WHERE (((tableA.[LOW_Right]) Is Not Null And (tableA.[LOW_Right])>0)) OR (((tableA.[UP_Right]) Is Not Null And (tableA.[UP_Right])>0));
UNION ALL
SELECT tableA.LOW_Left AS From, tableA.UP_Left AS To, 0 AS Status, tableA.STREET AS FullStreetAddress
FROM tableA
WHERE (((tableA.LOW_Left) Is Not Null And (tableA.LOW_Left)>0)) Or (((tableA.UP_Left) Is Not Null And (tableA.UP_Left)>0));
This is the result from above query:
From To Status FullStreetAddress
1000 5000 1 1251 Smith Rd
1000 5998 1 1251 Smith Rd
3001 6701 0 521 St. Albert St
1581 6701 0 521 St. Albert St
125 4523 1 1258 Bellpart
Now i need help to show only those records with no duplicate on FullStreetAddress.
For each tableA.STREET, If LOW_Right > 0 and there are multiple rows of tableA.STREET and LOW_Right that have the same value, only the row that has the highest UP_Right value should be shown
For each tableA.STREET, If LOW_Left > 0 and there are multiple rows of tableA.STREET and LOW_Left that have the same value, only the row that has the highest UP_Left value should be shown
For each tableA.STREET, If UP_Right > 0 and there are multiple rows of tableA.STREET and UP_Right that have the same value, only the row that has the lowest LOW_Right value should be shown
For each tableA.STREET, If UP_Left > 0 and there are multiple rows of tableA.STREET and UP_Left that have the same value, only the row that has the lowest LOW_Left value should be shown
Result should be shown like this:
From To Status FullStreetAddress
1000 5998 1 1251 Smith Rd (show highest UP_RIGHT)
1581 6701 0 521 St. Albert St (show lowest LOW_left)
125 4523 1 1258 Bellpart
Thanks in advance.
I'm very appreciated for your help.
TN
I created an access query with union. Everything is working fine now. But i would like to eliminate the duplicate records if more than one have the same Full street address.
Here is my query:
SELECT tableA.LOW_Right as From, tableA.UP_Right AS To, 1 AS Status, tableA.STREET AS FullStreetAddress
FROM tableA
WHERE (((tableA.[LOW_Right]) Is Not Null And (tableA.[LOW_Right])>0)) OR (((tableA.[UP_Right]) Is Not Null And (tableA.[UP_Right])>0));
UNION ALL
SELECT tableA.LOW_Left AS From, tableA.UP_Left AS To, 0 AS Status, tableA.STREET AS FullStreetAddress
FROM tableA
WHERE (((tableA.LOW_Left) Is Not Null And (tableA.LOW_Left)>0)) Or (((tableA.UP_Left) Is Not Null And (tableA.UP_Left)>0));
This is the result from above query:
From To Status FullStreetAddress
1000 5000 1 1251 Smith Rd
1000 5998 1 1251 Smith Rd
3001 6701 0 521 St. Albert St
1581 6701 0 521 St. Albert St
125 4523 1 1258 Bellpart
Now i need help to show only those records with no duplicate on FullStreetAddress.
For each tableA.STREET, If LOW_Right > 0 and there are multiple rows of tableA.STREET and LOW_Right that have the same value, only the row that has the highest UP_Right value should be shown
For each tableA.STREET, If LOW_Left > 0 and there are multiple rows of tableA.STREET and LOW_Left that have the same value, only the row that has the highest UP_Left value should be shown
For each tableA.STREET, If UP_Right > 0 and there are multiple rows of tableA.STREET and UP_Right that have the same value, only the row that has the lowest LOW_Right value should be shown
For each tableA.STREET, If UP_Left > 0 and there are multiple rows of tableA.STREET and UP_Left that have the same value, only the row that has the lowest LOW_Left value should be shown
Result should be shown like this:
From To Status FullStreetAddress
1000 5998 1 1251 Smith Rd (show highest UP_RIGHT)
1581 6701 0 521 St. Albert St (show lowest LOW_left)
125 4523 1 1258 Bellpart
Thanks in advance.
I'm very appreciated for your help.
TN