Project

General

Profile

1 373 aaronmk
SELECT '# projects' AS ___;
2 371 aaronmk
SELECT count(*) AS count FROM projects;
3 368 aaronmk
4 374 aaronmk
SELECT 'projects' AS ___;
5 4469 aaronmk
SELECT CAST(project_id AS text) AS project FROM projects ORDER BY project;
6 368 aaronmk
7 4469 aaronmk
SELECT 'each project''s # locations' AS ___;
8 377 aaronmk
SELECT
9 4469 aaronmk
    CAST(projects.project_id AS text) AS project
10
    , count("PlotID") AS locations_count
11 371 aaronmk
FROM projects
12 4469 aaronmk
JOIN "plotMetadata" ON "plotMetadata".project_id = projects.project_id
13 371 aaronmk
GROUP BY project
14
ORDER BY project
15
;
16
17 616 aaronmk
SELECT '# locations' AS ___;
18 4470 aaronmk
SELECT count(DISTINCT COALESCE("LatDec", 'NaN')||':'||COALESCE("LongDec", 'NaN')) AS count FROM "plotMetadata"
19 1157 aaronmk
;
20 376 aaronmk
21 1083 aaronmk
SELECT '# location events' AS ___;
22 4469 aaronmk
SELECT count(*) AS count FROM "plotMetadata";
23 374 aaronmk
24 377 aaronmk
SELECT '1st methods' AS ___;
25
SELECT DISTINCT
26 4469 aaronmk
    CAST(projects.project_id AS text) AS project
27
    , "PlotMethod" AS method
28 377 aaronmk
FROM projects
29 4469 aaronmk
JOIN "plotMetadata" ON "plotMetadata".project_id = projects.project_id
30 377 aaronmk
ORDER BY project, method
31 368 aaronmk
LIMIT 10;
32
33 1083 aaronmk
SELECT '1st observation measures' AS ___;
34 377 aaronmk
SELECT DISTINCT
35 4469 aaronmk
    CAST(projects.project_id AS text) AS project
36
    , "lookup_MethodCode"."Description" AS observationmeasure
37 377 aaronmk
FROM projects
38 4469 aaronmk
JOIN "plotMetadata" ON "plotMetadata".project_id = projects.project_id
39
JOIN "lookup_MethodCode" ON "lookup_MethodCode"."MethodCode" = "plotMetadata"."MethodCode"
40 1083 aaronmk
ORDER BY project, observationmeasure
41 377 aaronmk
LIMIT 10;
42
43
/*
44 368 aaronmk
SELECT p.PlotID, p.SiteCode, COUNT(*)
45 4469 aaronmk
FROM projects pr JOIN "plotMetadata" p JOIN plotObservations o
46 368 aaronmk
ON pr.project_id=p.project_id AND p.PlotID=o.PlotID
47
WHERE p.project_id=2
48
GROUP BY p.PlotID, p.SiteCode;
49
50
SELECT NoInd, COUNT(*) AS observations
51 4469 aaronmk
FROM plotObservations o JOIN "plotMetadata" p
52 368 aaronmk
ON o.PlotID=p.PlotID
53
WHERE project_id=2
54
GROUP BY NoInd;
55
56
SELECT p.PlotID, p.SiteCode, SUM(NoInd) AS Individuals
57 4469 aaronmk
FROM projects pr JOIN "plotMetadata" p JOIN plotObservations o
58 368 aaronmk
ON pr.project_id=p.project_id AND p.PlotID=o.PlotID
59
WHERE p.project_id=2
60
GROUP BY p.PlotID, p.SiteCode;
61
62 4469 aaronmk
SELECT DISTINCT "pr".project_id, project_name, "PlotMethod", m."MethodCode", m."Description"
63
FROM projects pr JOIN "plotMetadata" p JOIN "lookup_MethodCode" m
64
ON pr.project_id=p.project_id AND p."MethodCode"=m."MethodCode"
65
WHERE m."MethodCode"=8;
66 368 aaronmk
67
SELECT NoInd, COUNT(*) AS observations
68 4469 aaronmk
FROM plotObservations o JOIN "plotMetadata" p JOIN "lookup_MethodCode" m
69
ON o.PlotID=p.PlotID AND p."MethodCode"=m."MethodCode"
70 368 aaronmk
WHERE project_id=2
71
GROUP BY NoInd;
72
73
SELECT p.PlotID, p.SiteCode, SUM(NoInd) AS Individuals
74 4469 aaronmk
FROM projects pr JOIN "plotMetadata" p JOIN plotObservations o
75 368 aaronmk
ON pr.project_id=p.project_id AND p.PlotID=o.PlotID
76
WHERE p.project_id=1
77
GROUP BY p.PlotID, p.SiteCode
78
LIMIT 10;
79
80 4469 aaronmk
SELECT "PlotMethod", "MethodCode", "Description", COUNT(project_id) as projects
81 368 aaronmk
FROM (
82 4469 aaronmk
SELECT DISTINCT "p"."PlotMethod", p."MethodCode", p."Description", p.project_id
83 368 aaronmk
FROM (
84 4469 aaronmk
SELECT project_id, PlotID, "PlotMethod", m."MethodCode", m."Description"
85
FROM "plotMetadata" p JOIN "lookup_MethodCode" m
86
ON p."MethodCode"=m."MethodCode"
87 368 aaronmk
) p JOIN plotObservations o JOIN stems s
88
ON p.PlotID=o.PlotID AND o.PlotObsID=s.PlotObsID
89
GROUP BY project_id
90
) AS a
91 4469 aaronmk
GROUP BY "PlotMethod", "MethodCode", "Description";
92 368 aaronmk
93 4469 aaronmk
SELECT DISTINCT "pr".project_id, project_name
94
FROM projects pr JOIN "plotMetadata" p JOIN plotObservations o JOIN stems s
95 368 aaronmk
ON pr.project_id=p.project_id AND p.PlotID=o.PlotID AND o.PlotObsID=s.PlotObsID
96 4469 aaronmk
WHERE p."MethodCode"=3;
97 368 aaronmk
98
SELECT p.PlotID, SiteName as plot, COUNT(*) AS stems
99 4469 aaronmk
FROM "plotMetadata" p JOIN plotObservations o JOIN stems s
100 368 aaronmk
ON p.PlotID=o.PlotID AND o.PlotObsID=s.PlotObsID
101
WHERE p.project_id=2
102
GROUP BY p.PlotID, SiteName
103
LIMIT 10;
104
105 4469 aaronmk
SELECT p.PlotID, SiteName AS plot, COUNT(DISTINCT "Family", Genus, Species) AS SpeciesCount
106
FROM "plotMetadata" p JOIN plotObservations o
107 368 aaronmk
ON p.PlotID=o.PlotID
108
WHERE project_id=2
109
GROUP BY p.PlotID, SiteName;
110
111 4469 aaronmk
SELECT DISTINCT "p".PlotID, SiteName AS plot, Family, CONCAT_WS(' ',IFNULL(Genus,''), IFNULL(Species,'')) AS SpeciesName
112
FROM "plotMetadata" p JOIN plotObservations o
113 368 aaronmk
ON p.PlotID=o.PlotID
114
WHERE p.PlotID=298;
115
116
SELECT name_status, count(*) FROM plotObservations GROUP BY name_status;
117
118 4469 aaronmk
SELECT DISTINCT "p".PlotID, SiteName AS plot, Family,
119 368 aaronmk
CONCAT_WS(' ',IFNULL(Genus,''), IFNULL(Species,'')) AS SpeciesName, name_status
120 4469 aaronmk
FROM "plotMetadata" p JOIN plotObservations o
121 368 aaronmk
ON p.PlotID=o.PlotID
122
WHERE p.PlotID=298;
123
124 4469 aaronmk
SELECT DISTINCT "p".PlotID, SiteName AS plot, Family,
125 368 aaronmk
CONCAT_WS(' ',IFNULL(Genus,''), IFNULL(Species,'')) AS SpeciesName, name_status
126 4469 aaronmk
FROM "plotMetadata" p JOIN plotObservations o
127 368 aaronmk
ON p.PlotID=o.PlotID
128
WHERE p.PlotID=298 AND name_status=1;
129
130
SELECT p.PlotID, SiteCode AS plot, o.Line as subplot, COUNT(*) AS individuals
131 4469 aaronmk
FROM "plotMetadata" p JOIN plotObservations o
132 368 aaronmk
ON p.PlotID=o.PlotID
133
WHERE p.PlotID=298
134
GROUP BY p.PlotID, plot, subplot;
135
136
SELECT p.PlotID, SiteCode AS plot, o.Line as subplot, SUM(NoInd) AS individuals
137 4469 aaronmk
FROM "plotMetadata" p JOIN plotObservations o
138 368 aaronmk
ON p.PlotID=o.PlotID
139
WHERE p.PlotID=298
140
GROUP BY p.PlotID, plot, subplot;
141
142
SELECT p.PlotID, SiteCode AS plot, o.Line as subplot, SUM(NoInd) AS individuals
143 4469 aaronmk
FROM "plotMetadata" p JOIN plotObservations o
144 368 aaronmk
ON p.PlotID=o.PlotID
145
WHERE p.PlotID=1
146
GROUP BY p.PlotID, plot, subplot;
147
148 4469 aaronmk
SELECT COUNT(*) FROM "plotMetadata" WHERE "MethodCode"=1;
149 368 aaronmk
150 4469 aaronmk
SELECT PlotID FROM "plotMetadata" WHERE "MethodCode"=1 LIMIT 1;
151 368 aaronmk
152
SELECT p.PlotID, SiteCode AS plot, Family,
153
CONCAT_WS(' ',IFNULL(Genus,''), IFNULL(Species,'')) AS SpeciesName, cover_percent
154 4469 aaronmk
FROM "plotMetadata" p JOIN plotObservations o
155 368 aaronmk
ON p.PlotID=o.PlotID
156
WHERE p.PlotID=24589;
157
158
SELECT p.PlotID, p.SiteCode as plot, Country, PolDiv1 AS stateProvince, pol2 AS countyParish,
159
LatDec as latitude, LongDec as longitude, Elev as elevation
160 4469 aaronmk
FROM projects pr JOIN "plotMetadata" p
161 368 aaronmk
ON pr.project_id=p.project_id
162
WHERE pr.project_id=1
163
LIMIT 20;
164
165
SELECT AccessCode, COUNT(*)
166 4469 aaronmk
FROM "plotMetadata"
167 368 aaronmk
GROUP BY AccessCode;
168
169
SELECT pr.project_id, project_name, project_pi, allow_download_all, PlotID, SiteCode, Country
170 4469 aaronmk
FROM projects pr JOIN "plotMetadata" p
171 368 aaronmk
ON pr.project_id=p.project_id
172
WHERE p.AccessCode=1;
173
*/