Extends aggregate SQL statements to allow sortations and correct slicing...

... and adds test