Working query with postgresql, extracts data from BBS database with lightning speed.