-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgddages.sql
24 lines (24 loc) · 1.07 KB
/
gddages.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// This is the strict chronology data, but does not give the geochron data. . .
SELECT ds.datasetid,
st.sitename,
dst.datasettype,
chroncontroltype,
agetype,
depth,
json_agg(age) AS ages,
CONCAT('https://dx.doi.org/', doi) AS doi
FROM
ndb.chroncontrols AS cc
JOIN ndb.chroncontroltypes AS cct ON cc.chroncontroltypeid = cct.chroncontroltypeid
JOIN ndb.chronologies AS chr ON chr.chronologyid = cc.chronologyid
JOIN ndb.agetypes AS aty ON aty.agetypeid = chr.agetypeid
JOIN ndb.datasets AS ds ON chr.collectionunitid = ds.collectionunitid
JOIN ndb.datasetpublications AS dsp ON dsp.datasetid = ds.datasetid
JOIN ndb.publications AS pub ON pub.publicationid = dsp.publicationid
JOIN ndb.datasettypes AS dst ON ds.datasettypeid = dst.datasettypeid
JOIN ndb.collectionunits AS cu ON cu.collectionunitid = ds.collectionunitid
JOIN ndb.sites AS st ON cu.siteid = st.siteid
WHERE pub.doi IS NOT NULL AND
NOT ds.datasettypeid = 1
GROUP BY dst.datasettype, chroncontroltype, agetype, depth, doi, ds.datasetid, st.sitename
ORDER BY doi, depth