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