1
|
SELECT * FROM (SELECT
|
2
|
a.id AS "id",
|
3
|
a.protocol AS "protocol",
|
4
|
coalesce(a.compatibility_override, a.compatibility) AS "compliance",
|
5
|
a.active AS "active",
|
6
|
a.baseurl AS "baseUrl",
|
7
|
ds.eosc_datasource_type AS "type",
|
8
|
coalesce(a.last_aggregation_date::text, a.last_download_date::text, '') AS "aggrDate",
|
9
|
coalesce(a.last_aggregation_total, a.last_download_total, 0) AS "aggrTotal",
|
10
|
coalesce(a.last_aggregation_mdid, a.last_download_objid, '') AS "aggrMdId",
|
11
|
coalesce(a.last_collection_date::text, '') AS "collDate",
|
12
|
coalesce(a.last_collection_total, 0) AS "collTotal",
|
13
|
coalesce(a.last_collection_mdid, '') AS "collMdId",
|
14
|
ds.id AS "dsId",
|
15
|
ds.officialname AS "name",
|
16
|
ds.englishname AS "alternativeName",
|
17
|
ds.namespaceprefix AS "prefix",
|
18
|
ds.websiteurl AS "websiteUrl",
|
19
|
coalesce((array_agg(o.country))[1], '-') AS "country",
|
20
|
(array_agg(o.legalname))[1] AS "organization",
|
21
|
ds.consenttermsofuse AS "consenttermsofuse",
|
22
|
ds.fulltextdownload AS "fulltextdownload"
|
23
|
FROM dsm_api a
|
24
|
LEFT OUTER JOIN dsm_services ds ON (a.service = ds.id)
|
25
|
LEFT OUTER JOIN dsm_service_organization dsorg ON (ds.id = dsorg.service)
|
26
|
LEFT OUTER JOIN dsm_organizations o ON (dsorg.organization = o.id)
|
27
|
WHERE ds.dedup_main_service = true
|
28
|
GROUP BY
|
29
|
a.id,
|
30
|
a.protocol,
|
31
|
a.compatibility_override,
|
32
|
a.compatibility,
|
33
|
a.active,
|
34
|
a.last_aggregation_date,
|
35
|
a.last_download_date,
|
36
|
a.last_collection_date,
|
37
|
a.last_aggregation_total,
|
38
|
a.last_download_total,
|
39
|
a.last_collection_total,
|
40
|
a.last_aggregation_mdid,
|
41
|
a.last_download_objid,
|
42
|
a.last_collection_mdid,
|
43
|
ds.id,
|
44
|
ds.officialname,
|
45
|
ds.englishname,
|
46
|
ds.namespaceprefix,
|
47
|
ds.websiteurl,
|
48
|
ds.consenttermsofuse,
|
49
|
ds.fulltextdownload,
|
50
|
eosc_datasource_type
|
51
|
) AS t WHERE
|