1
|
SELECT '# specimen replicates' AS ___;
|
2
|
SELECT count(*) AS count FROM nybg_raw;
|
3
|
|
4
|
SELECT '# families' AS ___;
|
5
|
SELECT count(DISTINCT Family) AS count FROM nybg_raw;
|
6
|
|
7
|
SELECT '# genera' AS ___;
|
8
|
SELECT count(DISTINCT Genus) AS count FROM nybg_raw;
|
9
|
|
10
|
SELECT '# species' AS ___;
|
11
|
SELECT count(DISTINCT Genus, Species) AS count FROM nybg_raw;
|
12
|
|
13
|
SELECT '# binomials' AS ___;
|
14
|
SELECT count(DISTINCT ScientificName) AS count FROM nybg_raw;
|
15
|
|
16
|
/*
|
17
|
SELECT DISTINCT CONCAT_WS(' ', Genus, Species) AS Species
|
18
|
FROM nybg_raw
|
19
|
WHERE Genus IS NOT NULL AND Species IS NOT NULL;
|
20
|
|
21
|
SELECT DISTINCT Genus AS Genera
|
22
|
FROM nybg_raw
|
23
|
WHERE Genus IS NOT NULL;
|
24
|
|
25
|
SELECT DISTINCT Family as Families
|
26
|
FROM nybg_raw
|
27
|
WHERE Family IS NOT NULL;
|
28
|
|
29
|
SELECT ScientificName, Genus, Species, Subspecies, ScientificNameAuthor
|
30
|
FROM nybg_raw
|
31
|
LIMIT 25;
|
32
|
|
33
|
SELECT ScientificName, Genus, Species, Subspecies, ScientificNameAuthor
|
34
|
FROM nybg_raw
|
35
|
WHERE Subspecies IS NOT NULL
|
36
|
LIMIT 15;
|
37
|
|
38
|
SELECT InstitutionCode, COUNT(*) AS records
|
39
|
FROM nybg_raw
|
40
|
GROUP BY InstitutionCode;
|
41
|
|
42
|
SELECT DISTINCT CollectionCode
|
43
|
FROM nybg_raw;
|
44
|
|
45
|
SELECT DISTINCT Country, StateProvince, County
|
46
|
FROM nybg_raw
|
47
|
LIMIT 25;
|
48
|
|
49
|
SELECT COUNT(*) as totalRecords, COUNT(DISTINCT CatalogNumber) as uniqueCatalogNumbers
|
50
|
FROM nybg_raw;
|
51
|
|
52
|
SELECT CatalogNumber, COUNT(*) AS records
|
53
|
FROM nybg_raw
|
54
|
GROUP BY CatalogNumber
|
55
|
HAVING records>1;
|
56
|
|
57
|
SELECT b.CatalogNumber, DateLastModified, ScientificName, Collector, FieldNumber,
|
58
|
CollectedDate
|
59
|
FROM nybg_raw AS a JOIN (
|
60
|
SELECT CatalogNumber, COUNT(*) AS records
|
61
|
FROM nybg_raw
|
62
|
WHERE CatalogNumber IS NOT NULL
|
63
|
GROUP BY CatalogNumber
|
64
|
HAVING records>1
|
65
|
) AS b
|
66
|
ON a.CatalogNumber=b.CatalogNumber
|
67
|
ORDER BY b.CatalogNumber ASC, DateLastModified DESC;
|
68
|
|
69
|
SELECT DateLastModified, ScientificName, Collector, FieldNumber,
|
70
|
CollectedDate
|
71
|
FROM nybg_raw
|
72
|
WHERE CatalogNumber IS NULL
|
73
|
ORDER BY CatalogNumber ASC, DateLastModified DESC
|
74
|
LIMIT 12;
|
75
|
|
76
|
SELECT
|
77
|
(
|
78
|
SELECT COUNT(*)
|
79
|
FROM nybg_raw
|
80
|
WHERE Latitude IS NOT NULL
|
81
|
) AS allLats,
|
82
|
(
|
83
|
SELECT COUNT(*)
|
84
|
FROM nybg_raw
|
85
|
WHERE Latitude REGEXP '^(-|\\+){0,1}([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+|[0-9]+)$'
|
86
|
) AS decimalLats,
|
87
|
(
|
88
|
SELECT COUNT(*)
|
89
|
FROM nybg_raw
|
90
|
WHERE Longitude IS NOT NULL
|
91
|
) AS allLongs,
|
92
|
(
|
93
|
SELECT COUNT(*)
|
94
|
FROM nybg_raw
|
95
|
WHERE Longitude REGEXP '^(-|\\+){0,1}([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+|[0-9]+)$'
|
96
|
) AS decimalLongs;
|
97
|
|
98
|
SELECT Latitude, Longitude
|
99
|
FROM nybg_raw
|
100
|
WHERE Latitude IS NOT NULL AND Longitude IS NOT NULL
|
101
|
LIMIT 10;
|
102
|
|
103
|
SELECT
|
104
|
(
|
105
|
SELECT COUNT(*)
|
106
|
FROM nybg_raw
|
107
|
WHERE Latitude>90 OR Latitude<-90
|
108
|
) AS badLats,
|
109
|
(
|
110
|
SELECT COUNT(*)
|
111
|
FROM nybg_raw
|
112
|
WHERE Longitude>180 OR Longitude<-180
|
113
|
) AS badLongs;
|
114
|
|
115
|
SELECT DayCollected, MonthCollected, YearCollected
|
116
|
FROM nybg_raw
|
117
|
WHERE DayCollected IS NOT NULL OR MonthCollected IS NOT NULL OR YearCollected IS NOT NULL
|
118
|
LIMIT 10;
|
119
|
|
120
|
SELECT
|
121
|
(
|
122
|
SELECT COUNT(*)
|
123
|
FROM nybg_raw
|
124
|
WHERE NOT(DayCollected REGEXP '^-?[0-9]+$')
|
125
|
OR NOT(MonthCollected REGEXP '^-?[0-9]+$')
|
126
|
OR NOT(YearCollected REGEXP '^-?[0-9]+$')
|
127
|
) AS badDateCollected,
|
128
|
(
|
129
|
SELECT COUNT(*)
|
130
|
FROM nybg_raw
|
131
|
WHERE NOT(DayIdentified REGEXP '^-?[0-9]+$')
|
132
|
OR NOT(MonthIdentified REGEXP '^-?[0-9]+$')
|
133
|
OR NOT(YearIdentified REGEXP '^-?[0-9]+$')
|
134
|
) AS badDateIdentified;
|
135
|
|
136
|
SELECT Locality
|
137
|
FROM nybg_raw
|
138
|
WHERE Locality IS NOT NULL
|
139
|
LIMIT 10;
|
140
|
|
141
|
SELECT PlantFungusDescription
|
142
|
FROM nybg_raw
|
143
|
WHERE PlantFungusDescription IS NOT NULL
|
144
|
LIMIT 10;
|
145
|
|
146
|
SELECT Habitat, Vegetation
|
147
|
FROM nybg_raw
|
148
|
WHERE Habitat IS NOT NULL OR Vegetation IS NOT NULL
|
149
|
LIMIT 10;
|
150
|
*/
|