Create an alias for a builtin aggregate function
<p>I am using Postgres for local testing of a hosted database. The hosted database has a couple of functions that do not exist in Postgres. I don't need to replicate these functions, but I need to be able to call the functions with the same name and get a reasonable answer. For example, I would like to alias the count function to approximate_count_distinct. An example query would be:</p>

<pre><code>     select approximate_count_distinct(id)
     from table;
</code></pre>

<p>The behavior of this query would be exactly the same as count. I don't need to worry about the fact it's not exactly the same as on the hosted db</p>

<p>I have looked into CREATE AGGREGATE but can't get the arguments correct. Here is what i was trying to do for CREATE AGGREGATE:</p>

<pre><code>   CREATE AGGREGATE approximate_count_distinct(*) 
   ( 
     sfunc = count, 
     stype = bigint, 
     initcond = 0 
   );
</code></pre>

<p>but it wasn't compiling because it says 
<code>ERROR: function count(bigint) does not exist</code></p>

<p>I tried to find the right way to declare this function but got hopelessly lost. I looked in pg_proc but count seemed to be defined in a weird way as aggregate_dummy as the src symlink.</p>

<p>I looked into <code>ALIAS FOR</code> but that doesn't seem to work functions. </p>

<p>Long story short i don't know what to do to make it work. There surely must be an easy way to do this?</p>