Project

General

Profile

1 49970 michele.ar
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 50308 michele.ar
	a.typology                                                               AS "type",
8 49970 michele.ar
	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 50308 michele.ar
	coalesce((array_agg(o.country))[1], '-')                                 AS "country",
16 62012 michele.ar
    (array_agg(o.legalname))[1]                                              AS "organization",
17
    ds.consenttermsofuse                                                     AS "consenttermsofuse",
18
    ds.fulltextdownload                                                      AS "fulltextdownload"
19 49970 michele.ar
FROM dsm_api a
20 61861 michele.ar
	LEFT OUTER JOIN dsm_services ds ON (a.service = ds.id)
21 61864 michele.ar
	LEFT OUTER JOIN dsm_service_organization dsorg ON (ds.id = dsorg.service)
22 49970 michele.ar
	LEFT OUTER JOIN dsm_organizations o ON (dsorg.organization = o.id)
23 61991 michele.ar
WHERE ds.merged_in IS NULL
24 49970 michele.ar
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 62012 michele.ar
	ds.websiteurl,
39
	ds.consenttermsofuse,
40
    ds.fulltextdownload
41 50308 michele.ar
) AS t WHERE