Link to home
Start Free TrialLog in
Avatar of Sandman_19
Sandman_19

asked on

SQL Query filtering records

Re-posting for clarity

I need a query to filter out records that have identical values in the Project and Address fields where Status has 'In Progress' and 'Complete' so only the 'Complete' row is returned for those records.

Goal: When there are records with the same project and address with a status of both 'In Progress' and 'Complete' to eliminate the 'In Progress' records for that Project/Address.


Existing Table
ID    Project     Address     Status         Units
1        House1      Addr 1      In Progress     15
2        House1      Addr 1      In Progress       20
3        House1      Addr 1      In Progress     33
4        House1      Addr 1      Complete        42
5        House1      Addr 1      Complete        12
6        House1      Addr 1      Complete        60
7        House2      Addr 2      In Progress     44
8        House2      Addr 2      In Progress     12
9        House2      Addr 2      In Progress     65
10       House2      Addr 2      Complete        87
11       House2      Addr 2      Complete        36
12       House2      Addr 2      Complete        45
13       House3      Addr 3      In Progress     84
14       House3      Addr 3      In Progress     21
15       House4      Addr 4      Complete        19
16       House4      Addr 4      Complete        74

Should Return:
ID    Project     Address     Status         Units
4        House1      Addr 1      Complete        42
5        House1      Addr 1      Complete        12
6        House1      Addr 1      Complete        60
10       House2      Addr 2      Complete        87
11       House2      Addr 2      Complete        36
12       House2      Addr 2      Complete        45
13       House3      Addr 3      In Progress     84
14       House3      Addr 3      In Progress     21
15       House4      Addr 4      Complete        19
16       House4      Addr 4      Complete        74
Avatar of Aneesh
Aneesh
Flag of Canada image

which version of sql server are you using ?
Avatar of Sandman_19
Sandman_19

ASKER

2005
ASKER CERTIFIED SOLUTION
Avatar of awking00
awking00
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect.

Thanks.
Perfect.