Select to view content in your preferred language

Can multiple subqueries be tied together?

568
1
10-30-2018 02:43 PM
MarkWoodruff
New Contributor

desktop definition query‌ subquery‌

Hello, I have a feature class called SupplyWells in a relationship class with a table called SamplingEvents.  For a specified Well Type, I want to find wells where there was no detections of contaminants in the first year of sampling and detections after that year.  Two fields in SamplingEvents that should answer this are Sampling_Detects_Flag and Days.  Sampling_Detects_Flag is either NULL for no detection or YES for detection.  Days is the number of days from the date of the first sampling event to the date of the sampling event of that record.

I've tried this: WELL_TYPE = 'WELL POINT' and EGAD_SEQ in (Select SAMPLE_POINT_SEQ from Sampling_Events where SAMPLE_DETECTION_FLAG is NULL and DAYS <= 365) and EGAD_SEQ in (Select SAMPLE_POINT_SEQ from Sampling_Events where SAMPLE_DETECTION_FLAG = 'YES' and DAYS > 365).  However, it returns wells with at least one non-detect during the first 365 days.  I want no detections during the first 365 days.

The attached image shows for the WELL POINT meets the 2 criteria: there were no detections <= 365 days and there were detections > 365 days (at Day 1704). 

Your assistance is appreciated.

0 Kudos
1 Reply
JoshuaBixby
MVP Esteemed Contributor

GeoNet Resource Hub‌ is focused on GeoNet, and isn't an overly active space.  Tagging like you did is helpful, but posting or sharing to more relevant spaces will increase visibility:  https://community.esri.com/docs/DOC-1544-geonet-community-structure .

Sharing with GIS‌ and Analysis‌ and Geodatabase