This is a related question to the "ArcGIS Pro Definition Query to select a group of rows with all the same attribute" post.
In working with water well data the glacial drift deposits (AQTYPE=D) overly bedrock formations (AQTYPE=R). So for a given well there are typically all AQTYPE=D above AQTYPE=R. So in the table below and attached, well number 19000000008 is correct where the upper lithologies are all AQTYPE=D above AQTYPE=R lithologies.
Well number 19000000009 is not typical and in most cases incorrect in that it has an AQTYPE=R up within the glacial drift deposits. So the sequence is out of order in having AQTYPE=D deposits below AQTYPE=R deposits. Likely a data entry error where the Granite (AQTYPE=R) in 19000000009 should have been Gravel (AQTYPE=D).
I am trying to write an ArcGIS Pro Definition Query that will just select a lithology if the sequence was out of order for a given well: AQTYPE=D deposits below AQTYPE=R in the well 19000000009 above. So it would select this row
19000000009 | 2 | Granite | 52 | 2 | R |
I am also trying to write an ArcGIS Pro Definition Query that will just select a true uppermost rock lithology AQTYPE=R.
So it the this case the results would be
19000000008 | 5 | Shale | 160 | 51 | R |
and
19000000009 | 6 | Shale | 124 | 4 | R |
Thanks
WELLID | SEQ_NUM | PRIM_LITH | DEPTH | THICKNESS | AQTYPE |
19000000008 | 1 | Sand & Clay | 14 | 14 | D |
19000000008 | 2 | Clay | 34 | 20 | D |
19000000008 | 3 | Sand & Gravel | 69 | 35 | D |
19000000008 | 4 | Clay & Gravel | 109 | 40 | D |
19000000008 | 5 | Shale | 160 | 51 | R |
19000000008 | 6 | Sandstone | 215 | 55 | R |
19000000009 | 1 | Clay | 50 | 50 | D |
19000000009 | 2 | Granite | 52 | 2 | R |
19000000009 | 3 | Clay & Stones | 90 | 38 | D |
19000000009 | 4 | Gravel | 100 | 10 | D |
19000000009 | 5 | Clay | 120 | 20 | D |
19000000009 | 6 | Shale | 124 | 4 | R |
19000000009 | 7 | Shale | 130 | 6 | R |
19000000009 | 8 | Shale & Sandstone | 139 | 9 | R |
19000000009 | 9 | Sandstone | 160 | 21 | R |
19000000009 | 10 | Sandstone | 170 | 10 | R |
19000000009 | 11 | Sandstone | 222 | 52 | R |
I