Project

General

Profile

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
SELECT 'collection codes' AS ___;
17
SELECT DISTINCT CollectionCode AS collectioncode_dwc FROM nybg_raw;
18

    
19
SELECT '# catalog numbers' AS ___;
20
SELECT count(DISTINCT CatalogNumber) AS count FROM nybg_raw;
21

    
22
/*
23
SELECT DISTINCT Country, StateProvince, County 
24
FROM nybg_raw
25
LIMIT 25;
26

    
27
SELECT COUNT(*) as totalRecords, COUNT(DISTINCT CatalogNumber) as uniqueCatalogNumbers
28
FROM nybg_raw;
29

    
30
SELECT CatalogNumber, COUNT(*) AS records
31
FROM nybg_raw
32
GROUP BY CatalogNumber
33
HAVING records>1;
34

    
35
SELECT b.CatalogNumber, DateLastModified, ScientificName, Collector, FieldNumber, 
36
CollectedDate
37
FROM nybg_raw AS a JOIN (
38
SELECT CatalogNumber, COUNT(*) AS records
39
FROM nybg_raw
40
WHERE CatalogNumber IS NOT NULL
41
GROUP BY CatalogNumber
42
HAVING records>1
43
) AS b
44
ON a.CatalogNumber=b.CatalogNumber
45
ORDER BY b.CatalogNumber ASC, DateLastModified DESC;
46

    
47
SELECT DateLastModified, ScientificName, Collector, FieldNumber, 
48
CollectedDate
49
FROM nybg_raw 
50
WHERE CatalogNumber IS NULL
51
ORDER BY CatalogNumber ASC, DateLastModified DESC
52
LIMIT 12;
53

    
54
SELECT 
55
(
56
SELECT COUNT(*)
57
FROM nybg_raw
58
WHERE Latitude IS NOT NULL
59
) AS allLats,
60
(
61
SELECT COUNT(*)
62
FROM nybg_raw
63
WHERE Latitude REGEXP '^(-|\\+){0,1}([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+|[0-9]+)$'
64
) AS decimalLats,
65
(
66
SELECT COUNT(*)
67
FROM nybg_raw
68
WHERE Longitude IS NOT NULL
69
) AS allLongs,
70
(
71
SELECT COUNT(*)
72
FROM nybg_raw
73
WHERE Longitude REGEXP '^(-|\\+){0,1}([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+|[0-9]+)$'
74
) AS decimalLongs;
75

    
76
SELECT Latitude, Longitude 
77
FROM nybg_raw
78
WHERE  Latitude IS NOT NULL AND  Longitude IS NOT NULL
79
LIMIT 10;
80

    
81
SELECT 
82
(
83
SELECT COUNT(*)
84
FROM nybg_raw
85
WHERE Latitude>90 OR Latitude<-90
86
) AS badLats,
87
(
88
SELECT COUNT(*)
89
FROM nybg_raw
90
WHERE Longitude>180 OR Longitude<-180
91
) AS badLongs;
92

    
93
SELECT DayCollected, MonthCollected, YearCollected 
94
FROM nybg_raw
95
WHERE DayCollected IS NOT NULL OR MonthCollected IS NOT NULL OR YearCollected IS NOT NULL
96
LIMIT 10;
97

    
98
SELECT
99
(
100
SELECT COUNT(*)
101
FROM nybg_raw
102
WHERE NOT(DayCollected REGEXP '^-?[0-9]+$')
103
OR NOT(MonthCollected REGEXP '^-?[0-9]+$')
104
OR NOT(YearCollected REGEXP '^-?[0-9]+$')
105
) AS badDateCollected,
106
(
107
SELECT COUNT(*)
108
FROM nybg_raw
109
WHERE NOT(DayIdentified REGEXP '^-?[0-9]+$')
110
OR NOT(MonthIdentified REGEXP '^-?[0-9]+$')
111
OR NOT(YearIdentified REGEXP '^-?[0-9]+$')
112
) AS badDateIdentified;
113

    
114
SELECT Locality
115
FROM nybg_raw
116
WHERE Locality IS NOT NULL
117
LIMIT 10;
118

    
119
SELECT PlantFungusDescription
120
FROM nybg_raw
121
WHERE PlantFungusDescription IS NOT NULL
122
LIMIT 10;
123

    
124
SELECT Habitat, Vegetation
125
FROM nybg_raw
126
WHERE Habitat IS NOT NULL OR Vegetation IS NOT NULL
127
LIMIT 10;
128
*/
(2-2/2)