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
FROM dsm_api a
18
	LEFT OUTER JOIN dsm_services ds ON (a.service = ds.id)
19
	LEFT OUTER JOIN dsm_datasource_organization dsorg ON (ds.id = dsorg.datasource)
20
	LEFT OUTER JOIN dsm_organizations o ON (dsorg.organization = o.id)
21
GROUP BY
22
	a.id,
23
	a.protocol,
24
	a.compatibility_override,
25
	a.compatibility,
26
	a.active,
27
	a.last_aggregation_date,
28
	a.last_download_date,
29
	a.last_aggregation_total,
30
	a.last_download_total,
31
	ds.id,
32
	ds.officialname,
33
	ds.englishname,
34
	ds.namespaceprefix,
35
	ds.websiteurl
36
) AS t WHERE
(15-15/24)