Pass extra parameter to PostgreSQL aggregate final function

前端 未结 3 506
甜味超标
甜味超标 2020-12-18 09:39

Is the only way to pass an extra parameter to the final function of a PostgreSQL aggregate to create a special TYPE for the state value?

e.g.:

CREATE         


        
3条回答
  •  我在风中等你
    2020-12-18 10:33

    You would have to rewrite the final function itself, and in that case you might as well write a set of new aggregate functions, one for each possible COMPUTE_METHOD. If the COMPUTE_METHOD is a data value or implied by a data value, then a CASE statement can be used to select the appropriate aggregate method. Alternatively, you may want to create a custom composite type with fields for accum_number and COMPUTE_METHOD, and write a single new aggregate function that uses this new data type.

提交回复
热议问题