Project

General

Profile

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
	a.typology                                                               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
	ds.id                                                                    AS "dsId",
11
	ds.officialname                                                          AS "name",
12
	ds.englishname                                                           AS "alternativeName",
13
	ds.namespaceprefix                                                       AS "prefix",
14
	ds.websiteurl                                                            AS "websiteUrl",
15
	coalesce((array_agg(o.country))[1], '-')                                 AS "country",
16
    (array_agg(o.legalname))[1]                                              AS "organization",
17
    ds.consenttermsofuse                                                     AS "consenttermsofuse",
18
    ds.fulltextdownload                                                      AS "fulltextdownload"
19
FROM dsm_api a
20
	LEFT OUTER JOIN dsm_services ds ON (a.service = ds.id)
21
	LEFT OUTER JOIN dsm_service_organization dsorg ON (ds.id = dsorg.service)
22
	LEFT OUTER JOIN dsm_organizations o ON (dsorg.organization = o.id)
23
WHERE ds.merged_in IS NULL
24
GROUP BY
25
	a.id,
26
	a.protocol,
27
	a.compatibility_override,
28
	a.compatibility,
29
	a.active,
30
	a.last_aggregation_date,
31
	a.last_download_date,
32
	a.last_aggregation_total,
33
	a.last_download_total,
34
	ds.id,
35
	ds.officialname,
36
	ds.englishname,
37
	ds.namespaceprefix,
38
	ds.websiteurl,
39
	ds.consenttermsofuse,
40
    ds.fulltextdownload
41
) AS t WHERE
(16-16/25)