Implemented several aggregate functions

to be used by 'by'