I have a GIS layer that has thousands of Facility IDs.
- For each Facility ID there can be multiple Chemical ID's.
- For each chemical ID there is a maximum of 3 zone types. Zone A, B, C. But there is not always 3 Zone types, it varies.
- And the amount of chemical ID's for each Facility ID can vary from 1 to many.
What I am attempting to do, is Dissolve (or group by) this layer down to display which Facility ID Zone has the largest Buffer Distance while including the ZoneType(important)
Here are the fields
FacilityID, ChemicalID, ZoneType, ZoneDistance
ex rows: 1 2 A 1000
1 2 B 900
1 2 C 500
1 5 A 1200
1 5 B 900
1 7 B 2000
1 7 C 900
2 13 A 200
2 13 B 300
2 13 C 600
expected result: 1 row for every FacilityID with the Max Buffer and that specific zone type. So for FacilityID 1- I want one row and it would be ZoneType B with a ZoneDistance of 2000
FacilityID,ZoneType, ZoneDistance
1 B 2000
2 C 600
I have tried a few SQL statement which I got the Facility ID with the Max ZoneDistance for each ZoneType. I just want the Max ZoneDistance for all the ZoneTypes at a FacilityID.
SELECT max(ZoneDistance), ZoneType, FacilityID
FROM AllZones group by ZoneType, FacilityID;
I have also tried a Subquery but that did not work either
I am semi new to SQL, and I cannot seem to figure out the logic to get my results. Answers welcomed in SQL or Python