Good Morning/Afternoon,
I will attempt to phrase this correctly. I have a table with multiple fields that I am trying to create certain output results on in a query.
QueryA:
| Property | Bldg | Unit | Flag1 | Date1 | Cost1 |
|---|---|---|---|---|---|
| 1 | A | 1 | Y | 1/1/2022 | $1,000 |
| 2 | A | 1 | Y | 1/1/2022 | $2,000 |
| 2 | A | 1 | N | 1/1/2022 | $1,000 |
| 3 | A | 1 | N | 1/1/2022 | $1,000 |
| 3 | A | 1 | N | 1/1/2022 | $1,000 |
| 4 | A | 1 | Y | 5/5/2022 | $1,000 |
| 4 | A | 1 | N | 1/1/2022 | $1,000 |
| 5 | A | 1 | Y | 1/1/2022 | $1,000 |
| 5 | A | 1 | N | 1/1/2022 | $1,000 |
I would like to create the desired output below:
| Property | Bldg | Unit | Flag1 | Date1 | Cost1 |
|---|---|---|---|---|---|
| 1 | A | 1 | Y | 1/1/2022 | $1,000 |
| 2 | A | 1 | Y | 1/1/2022 | $2,000 |
| 3 | A | 1 | N | 1/1/2022 | $1,000 |
| 4 | A | 1 | Y | 5/5/2022 | $1,000 |
| 5 | A | 1 | Y | 1/1/2022 | $1,000 |
Essentially if there is a Y flag then the table should pull that row. Barring that a single N field should be selected. I've tried Max(Flag1) but both Y and N rows are still pulled whenever another value in a different column is different.
Any help would be appreciated.