1
|
###############################################
|
2
|
-- Brad Boyle / SALVIAS plots validations
|
3
|
###############################################
|
4
|
|
5
|
-- extract of boyle-salvias plots for validation
|
6
|
-- these queries pull the original data from SALVIAS plots
|
7
|
-- project_id=2 is "SALVIAS:Boyle Transects"
|
8
|
|
9
|
USE salvias_plots;
|
10
|
|
11
|
-- Count of species per plot from three plots
|
12
|
SELECT PlotCode, COUNT(DISTINCT Family, Genus, Species) as totSpecies
|
13
|
FROM PlotMetadata p JOIN PlotObservations o
|
14
|
ON p.PlotID=o.PlotID
|
15
|
WHERE project_id=2
|
16
|
GROUP BY PlotCode
|
17
|
ORDER BY PlotCode;
|
18
|
|
19
|
-- List of species per plot, three plots
|
20
|
SELECT DISTINCT PlotCode, CONCAT(IF(Genus IS NULL OR Genus='',IFNULL(Family,''),''),' ',IFNULL(Genus,''),' ', IFNULL(Species,'')) AS morphospecies
|
21
|
FROM PlotObservations
|
22
|
WHERE PlotCode IN ('m2250-1','c2250-1','e2250-1')
|
23
|
ORDER BY PlotCode, morphospecies;
|
24
|
|
25
|
-- Count of individuals per species, same plots
|
26
|
SELECT
|
27
|
PlotCode,
|
28
|
CONCAT(IF(Genus IS NULL OR Genus='',IFNULL(Family,''),''),' ',IFNULL(Genus,''),' ', IFNULL(Species,'')) AS morphospecies,
|
29
|
SUM(NoInd) AS individuals
|
30
|
FROM PlotObservations
|
31
|
WHERE PlotCode IN ('m2250-1','c2250-1','e2250-1')
|
32
|
GROUP BY PlotCode, morphospecies
|
33
|
ORDER BY PlotCode, morphospecies;
|
34
|
|
35
|
-- Count of stems >=2.5 cm dbh per individual, same plots
|
36
|
SELECT
|
37
|
PlotCode,
|
38
|
Ind as individualID,
|
39
|
CONCAT(IF(Genus IS NULL OR Genus='',IFNULL(Family,''),''),' ',IFNULL(Genus,''),' ', IFNULL(Species,'')) AS morphospecies,
|
40
|
COUNT(DISTINCT stem_id) AS stems
|
41
|
FROM PlotObservations o JOIN stems s
|
42
|
ON o.PlotObsID=s.PlotObsID
|
43
|
WHERE PlotCode IN ('m2250-1','c2250-1','e2250-1')
|
44
|
GROUP BY PlotCode, morphospecies, individualID
|
45
|
ORDER BY PlotCode, morphospecies, individualID;
|
46
|
|
47
|
-- Count of individuals with >= one stem >= 2.5 cm dbh per plot
|
48
|
SELECT
|
49
|
PlotCode, SUM(DISTINCT Ind) AS individuals
|
50
|
FROM PlotMetadata p JOIN PlotObservations o JOIN stems s
|
51
|
ON p.PlotID=o.PlotID AND o.PlotObsID=s.PlotObsID
|
52
|
WHERE project_id=2
|
53
|
AND stem_dbh>=2.5
|
54
|
GROUP BY PlotCode
|
55
|
ORDER BY PlotCode;
|
56
|
|
57
|
-- Count of stems >= 2.5 cm dbh per plot
|
58
|
SELECT
|
59
|
PlotCode, COUNT(DISTINCT stem_id) AS stems
|
60
|
FROM PlotMetadata p JOIN PlotObservations o JOIN stems s
|
61
|
ON p.PlotID=o.PlotID AND o.PlotObsID=s.PlotObsID
|
62
|
WHERE project_id=2
|
63
|
AND stem_dbh>=2.5
|
64
|
GROUP BY PlotCode
|
65
|
ORDER BY PlotCode;
|
66
|
|
67
|
-- Count of stems >=10 cm dbh per plot
|
68
|
SELECT
|
69
|
PlotCode, COUNT(DISTINCT stem_id) AS stems
|
70
|
FROM PlotMetadata p JOIN PlotObservations o JOIN stems s
|
71
|
ON p.PlotID=o.PlotID AND o.PlotObsID=s.PlotObsID
|
72
|
WHERE project_id=2
|
73
|
AND stem_dbh>=10
|
74
|
GROUP BY PlotCode
|
75
|
ORDER BY PlotCode;
|
76
|
|
77
|
|
78
|
|