-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshape.format
More file actions
35 lines (26 loc) · 1.81 KB
/
Copy pathshape.format
File metadata and controls
35 lines (26 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
attach database 'json.sqlite3' as shape;
select uuid, aenttypename, attributename, coalesce(group_concat(response, ''),'') as response
from (
select uuid, aenttypeid, aenttypename, coalesce(group_concat(format(formatstring, devocab, measure, freetext, certainty), appendcharacterstring),'') as response, null as deleted, aentcountorder, attributeid, attributename
from (
select uuid, aenttypeid, aenttypename, formatstring, devocab, replace(replace(measure, char(13), '\r'), char(10), '\n') as measure, replace(replace(freetext, char(13), '\r'), char(10), '\n') as freetext, certainty, appendcharacterstring, null as deleted, aentcountorder, vocabcountorder, attributeid, attributename, vocabname
from latestNonDeletedArchent
JOIN aenttype using (aenttypeid)
JOIN idealaent using (aenttypeid)
join attributekey using (attributeid)
left outer join latestNonDeletedAentValue using (uuid, attributeid)
left outer join (select vocabid, attributeid, coalesce(val, vocabname) as devocab, vocabcountorder, vocabname
from vocabulary
left outer join shape.keyval on (vocabulary.vocabname = keyval.key))
using (attributeid, vocabid)
order by uuid, aentcountorder, vocabcountorder
)
group by uuid, attributeid
having response is not null
order by uuid, aentcountorder)
group by uuid, attributeid
order by uuid;
select uuid, aenttypename, 'identifier', response
from latestNonDeletedArchEntFormattedIdentifiers join createdModifiedAtBy using (uuid)
order by createdAt;
detach database shape;