Setup query for recording table