diff --git a/scripts-available/CDB_Overviews.sql b/scripts-available/CDB_Overviews.sql index d3c12ca..43e2040 100644 --- a/scripts-available/CDB_Overviews.sql +++ b/scripts-available/CDB_Overviews.sql @@ -304,8 +304,9 @@ BEGIN -- 'A', 'B', 'A', 'C', 'D' => 'A/B/C/...' -- Other ideas: if value is unique then use it, otherwise use something -- like '*' or '(varies)' or '(multiple values)', or NULL - RETURN '''''::' || column_type; - ELSE RETURN 'NULL::' || column_type; + RETURN 'CASE count(*) WHEN 1 THEN string_agg(' || qualified_column || ',''/'') ELSE ''*''' || ' END::' || column_type; + ELSE + RETURN 'CASE count(*) WHEN 1 THEN MIN(' || qualified_column || ') ELSE NULL END::' || column_type; END CASE; END $$ LANGUAGE PLPGSQL IMMUTABLE;