Fixed a bug when using GROUP BY to remove duplicates caused by JOINs.