Project

General

Profile

« Previous | Next » 

Revision 12057

fix: validation/aggregating/traits/_archive/bien3_validations_traits_bien3.by=: renamed to indicate that this is actually not Brad's original file, as the filename would seem to indicate

View differences:

trunk/validation/aggregating/traits/_archive/bien3_validations_traits_bien3.by=Brad@iPlant.sql
1
-- -------------------------------------------------------------------------------
2
-- Quantitative validation queries against table Trait in BIEN3 postgres db
3
-- 
4
-- DB: vegbien
5
-- Host: vegbiendev.nceas.ucsb.edu
6
-- -------------------------------------------------------------------------------
7

  
8
-- ------------------
9
-- 1. Count records
10
-- ------------------
11
SELECT COUNT(*) AS totalRecords
12
FROM trait
13
;
14

  
15
-- ------------------
16
-- 2. Count trait names
17
-- ------------------
18
SELECT COUNT(DISTINCT name) AS traits
19
FROM trait
20
;
21

  
22
-- ------------------
23
-- 3. List trait names
24
-- ------------------
25
SELECT DISTINCT name AS trait
26
FROM trait
27
ORDER BY trait
28
;
29

  
30
-- ------------------
31
-- 4. Count records per trait
32
-- ------------------
33
SELECT name AS trait, COUNT(*) AS measurements
34
FROM trait
35
GROUP BY trait
36
ORDER BY trait
37
;
38

  
39
-- ------------------
40
-- 5. Count taxa
41
-- ------------------
42
SELECT COUNT(DISTINCT (taxonname, author)) AS taxa
43
FROM taxonverbatim
44
WHERE source_id = source_by_shortname('bien2_traits')
45
;
46

  
47
-- ------------------
48
-- 6. List distinct verbatim taxa
49
-- ------------------
50
SELECT DISTINCT concat_ws(' ', taxonname, author) AS taxonwithauthor
51
FROM taxonverbatim
52
WHERE source_id = source_by_shortname('bien2_traits')
53
ORDER BY taxonwithauthor
54
;
55

  
56
-- ------------------
57
-- 7. Trait, value and units
58
-- ------------------
59
SELECT name AS trait, value, units
60
FROM trait
61
ORDER BY trait, value, units
62
;
63

  
64
-- ------------------
65
-- 8. Taxon, trait and value for first 5000 records 
66
-- ------------------
67
SELECT concat_ws(' ', taxonname, author) AS taxonwithauthor, name AS trait, value
68
FROM taxonverbatim
69
JOIN taxondetermination ON taxondetermination.taxonverbatim_id = taxonverbatim.taxonverbatim_id AND taxondetermination.iscurrent
70
JOIN trait USING (taxonoccurrence_id)
71
WHERE taxonverbatim.source_id = source_by_shortname('bien2_traits')
72
ORDER BY taxonwithauthor, trait, value
73
;
trunk/validation/aggregating/traits/_archive/bien3_validations_traits_bien3.by=Brad@iPlant,Aaron@UCSB.sql
1
-- -------------------------------------------------------------------------------
2
-- Quantitative validation queries against table Trait in BIEN3 postgres db
3
-- 
4
-- DB: vegbien
5
-- Host: vegbiendev.nceas.ucsb.edu
6
-- -------------------------------------------------------------------------------
7

  
8
-- ------------------
9
-- 1. Count records
10
-- ------------------
11
SELECT COUNT(*) AS totalRecords
12
FROM trait
13
;
14

  
15
-- ------------------
16
-- 2. Count trait names
17
-- ------------------
18
SELECT COUNT(DISTINCT name) AS traits
19
FROM trait
20
;
21

  
22
-- ------------------
23
-- 3. List trait names
24
-- ------------------
25
SELECT DISTINCT name AS trait
26
FROM trait
27
ORDER BY trait
28
;
29

  
30
-- ------------------
31
-- 4. Count records per trait
32
-- ------------------
33
SELECT name AS trait, COUNT(*) AS measurements
34
FROM trait
35
GROUP BY trait
36
ORDER BY trait
37
;
38

  
39
-- ------------------
40
-- 5. Count taxa
41
-- ------------------
42
SELECT COUNT(DISTINCT (taxonname, author)) AS taxa
43
FROM taxonverbatim
44
WHERE source_id = source_by_shortname('bien2_traits')
45
;
46

  
47
-- ------------------
48
-- 6. List distinct verbatim taxa
49
-- ------------------
50
SELECT DISTINCT concat_ws(' ', taxonname, author) AS taxonwithauthor
51
FROM taxonverbatim
52
WHERE source_id = source_by_shortname('bien2_traits')
53
ORDER BY taxonwithauthor
54
;
55

  
56
-- ------------------
57
-- 7. Trait, value and units
58
-- ------------------
59
SELECT name AS trait, value, units
60
FROM trait
61
ORDER BY trait, value, units
62
;
63

  
64
-- ------------------
65
-- 8. Taxon, trait and value for first 5000 records 
66
-- ------------------
67
SELECT concat_ws(' ', taxonname, author) AS taxonwithauthor, name AS trait, value
68
FROM taxonverbatim
69
JOIN taxondetermination ON taxondetermination.taxonverbatim_id = taxonverbatim.taxonverbatim_id AND taxondetermination.iscurrent
70
JOIN trait USING (taxonoccurrence_id)
71
WHERE taxonverbatim.source_id = source_by_shortname('bien2_traits')
72
ORDER BY taxonwithauthor, trait, value
73
;

Also available in: Unified diff