Fixed up queries for postgres
Merge pull request #19 from stefk/postgres-fix

Fixed up queries for postgres