GROUP BY Conversion
In GROUP BY statements, non-group columns can be queried in MySQL and ADB, but only group columns and aggregate functions can be queried in DWS. To query non-group columns, you need to use the MySQL compatibility mode with disable_full_group_by_mysql enabled.
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 |
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 ORDER BY department_name; |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot