Query processing: fixed that group by queries can be called from Db.SQL. Reflected in regression tests. Fixes #1593.