A simple weighted mean aggregate function for postgresql