fixed unique bids query for postgres