Open missinglink opened 7 years ago
language coverage query:
#!/bin/bash
sqlite3 'data/store.sqlite3' <<SQL
SELECT e.key, COUNT(*) as total
FROM docs, json_each( json_extract( docs.json, '$.names' ) ) as e
GROUP BY e.key
ORDER BY total DESC
LIMIT 10;
SQL
eng|159741
nld|80673
spa|78875
fra|76680
ita|75671
por|71643
pol|64886
deu|64841
vol|52729
cat|51211
list all records with 5 lineages:
#!/bin/bash
sqlite3 'data/store.sqlite3' <<SQL
SELECT DISTINCT(id) FROM (
SELECT docs.id, 0 AS lineage, SUBSTR( key, 1, LENGTH( key ) -3 ), CAST( value AS INTEGER ) FROM docs, json_each( json_extract( docs.json, '$.lineage[0]' ) )
UNION ALL
SELECT docs.id, 1 AS lineage, SUBSTR( key, 1, LENGTH( key ) -3 ), CAST( value AS INTEGER ) FROM docs, json_each( json_extract( docs.json, '$.lineage[1]' ) )
UNION ALL
SELECT docs.id, 2 AS lineage, SUBSTR( key, 1, LENGTH( key ) -3 ), CAST( value AS INTEGER ) FROM docs, json_each( json_extract( docs.json, '$.lineage[2]' ) )
UNION ALL
SELECT docs.id, 3 AS lineage, SUBSTR( key, 1, LENGTH( key ) -3 ), CAST( value AS INTEGER ) FROM docs, json_each( json_extract( docs.json, '$.lineage[3]' ) )
UNION ALL
SELECT docs.id, 4 AS lineage, SUBSTR( key, 1, LENGTH( key ) -3 ), CAST( value AS INTEGER ) FROM docs, json_each( json_extract( docs.json, '$.lineage[4]' ) )
UNION ALL
SELECT docs.id, 5 AS lineage, SUBSTR( key, 1, LENGTH( key ) -3 ), CAST( value AS INTEGER ) FROM docs, json_each( json_extract( docs.json, '$.lineage[5]' ) )
)
WHERE lineage = 5
SQL
here's an example of running a SQL query to get statistical info from WOF admin records:
running the command outputs average populations grouped by placetype: