I want to write an aggregate function that returns a text formatted like: min -> max for an integer column, where
min and max are minimum and maximum values of that column.
For example:

```
SELECT min_to_max(val) FROM (VALUES(5),(3),(6),(7),(9),(10),(7)) t(val);

```

would return

```none
min_to_max
-----------
3 -> 10

```

I tried writing using a cursor but I think using a custom aggregate would be much better but I'm clueless how to write a custom aggregate.

What I have done is written a normal function:

```
create or replace function min_to_max()
returns varchar
language plpgsql
as
$$
declare
   answer varchar;
begin
   select MIN(val) || '->' ||  max(val)
   into answer
   from abc;

return answer;
end;
$$;

```