题目链接:点击打开链接
题目大意:略。
解题思路:注意 GROUP_CONCAT([DISTINCT] 连接字段 [Order BY ASC/DESC 排序字段] [Separator '分隔符'])。
AC 代码
WITH t AS(SELECT power, factor, CONCAT(IF(factor > 0, '+', '-'), ABS(factor), IF(power = 0, '', IF(power = 1, 'X', CONCAT('X^', power)))) equation FROM Terms) SELECT CONCAT(GROUP_CONCAT(equation ORDER BY power DESC SEPARATOR ''), '=0') equation FROM t