Preserve aggregated attributes of singleton groups

This commit is contained in:
Javier Goizueta 2015-12-29 14:56:47 +01:00
parent b34a752172
commit cecba655eb

View File

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