forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: luhuayi <luhuayi@huawei.com> Co-committed-by: luhuayi <luhuayi@huawei.com>
5.2 KiB
5.2 KiB
GROUP BY Conversion
During MySQL/ADB group query, non-group columns can be queried. During GaussDB(DWS) group query, only group columns and aggregate functions can be queried, and if non-group columns are queried, an error will be reported. Therefore, GROUP BY in GaussDB(DWS) is changed to allow querying on non-group columns.
Input
1 | SELECT e.department_id, department_name, ROUND(AVG(salary), 0) avg_salary FROM employees e JOIN departments d on e.department_id = d.department_id GROUP BY department_name ORDER BY department_name; |
Output
1 2 3 4 5 6 7 8 9 10 11 12 | SELECT e.department_id, department_name, ROUND (AVG(salary), 0) AS "avg_salary" FROM employees "e" JOIN departments "d" ON e.department_id = d.department_id GROUP BY department_name, 1 ORDER BY department_name; |
Parent topic: Data Manipulation Language (DML)