Project

General

Profile

1
SELECT 	 o.id										as organizationid, 
2
		 o.legalshortname							as legalshortname,
3
		 o.legalname                                as legalname,
4
		 o.websiteurl                               as websiteurl,
5
		 o.logourl                                  as logourl,
6
		 o.ec_legalbody                             as eclegalbody,
7
		 o.ec_legalperson                           as eclegalperson,
8
		 o.ec_nonprofit                             as ecnonprofit,
9
		 o.ec_researchorganization                  as ecresearchorganization,
10
		 o.ec_highereducation                       as echighereducation,
11
		 o.ec_internationalorganizationeurinterests as ecinternationalorganizationeurinterests,
12
		 o.ec_internationalorganization             as ecinternationalorganization,
13
		 o.ec_enterprise                            as ecenterprise,
14
		 o.ec_smevalidated                          as ecsmevalidated,
15
		 o.ec_nutscode                              as ecnutscode,
16
		 o.dateofcollection							as dateofcollection,
17
		 o.inferred                                 as inferred,
18
		 o.deletedbyinference                       as deletedbyinference,
19
		 o.trust                                    as trust,
20
		 o.inferenceprovenance                      as inferenceprovenance,
21
		 dc.id			                            as collectedfromid,
22
		 dc.officialname                            as collectedfromname,
23
		 
24
		 cc.code || '@@@' || cc.name || '@@@' || cs.code || '@@@' || cs.name	as country,
25
		 pac.code || '@@@' || pac.name || '@@@' || pas.code || '@@@' || pas.name	as provenanceaction,
26
		 
27
		 array_agg(DISTINCT i.pid || '###' || idc.code || '@@@' || idc.name || '@@@' || ids.code || '@@@' || ids.name)	as pid
28

    
29
FROM organizations o
30
	left outer join class cc on (cc.code = o.countryclass)	
31
	left outer join scheme cs on (cs.code = o.countryscheme)
32
	
33
	left outer join class pac on (pac.code = o.provenanceactionclass)	
34
	left outer join scheme pas on (pas.code = o.provenanceactionscheme)		
35
	
36
	left outer join organizationpids op on (op.organization = o.id)
37
	left outer join identities i on (i.pid = op.pid)
38
	
39
	left outer join datasources dc on (dc.id = o.collectedfrom)
40
	
41
	left outer join class idc on (idc.code = i.issuertypeclass)
42
	left outer join scheme ids on (ids.code = i.issuertypescheme)	
43
 
44
GROUP BY
45
		 o.id, 
46
		 o.legalshortname,
47
		 o.legalname,
48
		 o.websiteurl,
49
		 o.logourl,
50
		 o.ec_legalbody,
51
		 o.ec_legalperson,
52
		 o.ec_nonprofit,
53
		 o.ec_researchorganization,
54
		 o.ec_highereducation,
55
		 o.ec_internationalorganizationeurinterests,
56
		 o.ec_internationalorganization,
57
		 o.ec_enterprise,
58
		 o.ec_smevalidated,
59
		 o.ec_nutscode,
60
		 o.dateofcollection,
61
		 o.inferred,
62
		 o.deletedbyinference,
63
		 o.trust,
64
		 o.inferenceprovenance,
65
		 dc.id, 
66
		 dc.officialname, 
67
		 cc.code, cc.name, cs.code, cs.name,
68
		 pac.code, pac.name, pas.code, pas.name
69
		
(8-8/12)