Fixing single page aggregate sql issues