83 |
83 |
WHERE datasource_id =
|
84 |
84 |
(SELECT party_id FROM party WHERE organizationname = :datasource)
|
85 |
85 |
;
|
|
86 |
|
|
87 |
SELECT '# counties' AS ___;
|
|
88 |
SELECT count(DISTINCT
|
|
89 |
COALESCE(country_namedplace.placename, '')
|
|
90 |
||','|| COALESCE(state_namedplace.placename, '')
|
|
91 |
||','|| COALESCE(county_namedplace.placename, '')
|
|
92 |
) AS count
|
|
93 |
FROM specimenreplicate
|
|
94 |
JOIN taxonoccurrence USING (taxonoccurrence_id)
|
|
95 |
JOIN locationevent USING (locationevent_id)
|
|
96 |
JOIN locationdetermination AS country_locationdet
|
|
97 |
ON country_locationdet.location_id = locationevent.location_id
|
|
98 |
JOIN namedplace AS country_namedplace
|
|
99 |
ON country_namedplace.namedplace_id = country_locationdet.namedplace_id
|
|
100 |
AND country_namedplace.placesystem = 'area|country|territory'
|
|
101 |
JOIN locationdetermination AS state_locationdet
|
|
102 |
ON state_locationdet.location_id = locationevent.location_id
|
|
103 |
JOIN namedplace AS state_namedplace
|
|
104 |
ON state_namedplace.namedplace_id = state_locationdet.namedplace_id
|
|
105 |
AND state_namedplace.placesystem = 'region|state|province'
|
|
106 |
JOIN locationdetermination AS county_locationdet
|
|
107 |
ON county_locationdet.location_id = locationevent.location_id
|
|
108 |
JOIN namedplace AS county_namedplace
|
|
109 |
ON county_namedplace.namedplace_id = county_locationdet.namedplace_id
|
|
110 |
AND county_namedplace.placesystem = 'county'
|
|
111 |
WHERE specimenreplicate.datasource_id =
|
|
112 |
(SELECT party_id FROM party WHERE organizationname = :datasource)
|
|
113 |
;
|
specimens verification: Added # counties test