Fix identifier quoting on Oracle/Postgres

This fixes issue #885
Oracle and Postgres (at least) don't like to have quoted alias when trying
to group by them. This fix gets around the issue by quoting only identifiers
that have a space/dot in them.
Oh wow, definitely not!

How should I fix it? I am new to this pull request thing...