Project

General

Profile

1 1243 aaronmk
SELECT '# specimen replicates' AS ___;
2
SELECT count(*) AS count
3
FROM specimenreplicate
4 1249 aaronmk
WHERE datasource_id =
5
    (SELECT party_id FROM party WHERE organizationname = :datasource)
6 1243 aaronmk
;
7
8
SELECT '# families' AS ___;
9 1593 aaronmk
SELECT count(DISTINCT plantname.plantname_id) AS count
10 1243 aaronmk
FROM specimenreplicate
11
JOIN taxondetermination USING (taxonoccurrence_id)
12
JOIN plantconcept USING (plantconcept_id)
13 1593 aaronmk
JOIN plantname_ancestor USING (plantname_id)
14 1246 aaronmk
JOIN plantname
15 1593 aaronmk
    ON plantname.plantname_id = plantname_ancestor.ancestor_id
16
    AND plantname.rank = 'family'
17 1249 aaronmk
WHERE datasource_id =
18
    (SELECT party_id FROM party WHERE organizationname = :datasource)
19
AND taxondetermination.isoriginal
20 1243 aaronmk
;
21 1246 aaronmk
22
SELECT '# genera' AS ___;
23 1593 aaronmk
SELECT count(DISTINCT plantname.plantname_id) AS count
24 1246 aaronmk
FROM specimenreplicate
25
JOIN taxondetermination USING (taxonoccurrence_id)
26
JOIN plantconcept USING (plantconcept_id)
27 1593 aaronmk
JOIN plantname_ancestor USING (plantname_id)
28 1246 aaronmk
JOIN plantname
29 1593 aaronmk
    ON plantname.plantname_id = plantname_ancestor.ancestor_id
30
    AND plantname.rank = 'genus'
31 1249 aaronmk
WHERE datasource_id =
32
    (SELECT party_id FROM party WHERE organizationname = :datasource)
33
AND taxondetermination.isoriginal
34 1246 aaronmk
;
35
36
SELECT '# species' AS ___;
37 1252 aaronmk
SELECT
38 1593 aaronmk
    count(DISTINCT genus_plantname.plantname_id
39
        ||','||species_plantname.plantname_id) AS count
40 1246 aaronmk
FROM specimenreplicate
41 1593 aaronmk
JOIN taxondetermination USING (taxonoccurrence_id)
42
JOIN plantconcept USING (plantconcept_id)
43
JOIN plantname_ancestor USING (plantname_id)
44 1252 aaronmk
JOIN plantname AS genus_plantname
45 1593 aaronmk
    ON genus_plantname.plantname_id = plantname_ancestor.ancestor_id
46
    AND genus_plantname.rank = 'genus'
47 1252 aaronmk
JOIN plantname AS species_plantname
48 1593 aaronmk
    ON species_plantname.plantname_id = plantname_ancestor.ancestor_id
49
    AND species_plantname.rank = 'species'
50 1249 aaronmk
WHERE datasource_id =
51
    (SELECT party_id FROM party WHERE organizationname = :datasource)
52 1246 aaronmk
;
53 1254 aaronmk
54
SELECT '# binomials' AS ___;
55 1593 aaronmk
SELECT count(DISTINCT plantname.plantname_id) AS count
56 1254 aaronmk
FROM specimenreplicate
57
JOIN taxondetermination USING (taxonoccurrence_id)
58
JOIN plantconcept USING (plantconcept_id)
59 1593 aaronmk
JOIN plantname_ancestor USING (plantname_id)
60 1254 aaronmk
JOIN plantname
61 1593 aaronmk
    ON plantname.plantname_id = plantname_ancestor.ancestor_id
62
    AND plantname.rank = 'binomial'
63 1254 aaronmk
WHERE datasource_id =
64
    (SELECT party_id FROM party WHERE organizationname = :datasource)
65
AND taxondetermination.isoriginal
66
;
67 1297 aaronmk
68
SELECT 'collection codes' AS ___;
69
SELECT DISTINCT collectioncode_dwc
70
FROM specimenreplicate
71
WHERE datasource_id =
72
    (SELECT party_id FROM party WHERE organizationname = :datasource)
73
;
74
75
SELECT '# catalog numbers' AS ___;
76
SELECT count(DISTINCT catalognumber_dwc) AS count
77
FROM specimenreplicate
78
WHERE datasource_id =
79
    (SELECT party_id FROM party WHERE organizationname = :datasource)
80
;
81 1298 aaronmk
82 1300 aaronmk
SELECT 'duplicate catalog numbers' AS ___;
83
SELECT catalognumber_dwc, count(*) AS count
84
FROM specimenreplicate
85
WHERE datasource_id =
86
    (SELECT party_id FROM party WHERE organizationname = :datasource)
87
GROUP BY catalognumber_dwc
88
HAVING count(*) > 1
89 1302 aaronmk
ORDER BY catalognumber_dwc NULLS FIRST/* to match MySQL */
90 1300 aaronmk
;
91
92 1298 aaronmk
SELECT '# counties' AS ___;
93 1593 aaronmk
SELECT count(DISTINCT namedplace.namedplace_id) AS count
94 1298 aaronmk
FROM specimenreplicate
95
JOIN taxonoccurrence USING (taxonoccurrence_id)
96
JOIN locationevent USING (locationevent_id)
97 1325 aaronmk
JOIN locationdetermination USING (location_id)
98 1593 aaronmk
JOIN namedplace_ancestor USING (namedplace_id)
99
JOIN namedplace
100
    ON namedplace.namedplace_id = namedplace_ancestor.ancestor_id
101
    AND namedplace.rank = 'county'
102 1298 aaronmk
WHERE specimenreplicate.datasource_id =
103
    (SELECT party_id FROM party WHERE organizationname = :datasource)
104
;