Error code: 1582 Incorrect parameter count in the call to native function 'str _ to_date'
1. Error description
1 queries executed, 0 success, 1 errors, 0 warnings query: SELECT t. 'name', DATE_FORMAT (str_to_date ('20140901'), '% y') as statisDate, ROUND (IFNULL (SUM (t. 'amount '), 0), 3)... error code: 1582 Incorrect parameter count in the call to native function 'str _ to_date 'execution time: 0 sec Transfer Time: 0 sec total time consumed: 0 sec
2. Cause of error
SELECT t.`name`, DATE_FORMAT(STR_TO_DATE('2015'), '%Y') AS statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amountFROM t_stu_info t WHERE 1 = 1 AND DATE_FORMAT(t.statisDate, '%Y') = '2015' UNIONALL SELECT t.`name`, DATE_FORMAT(STR_TO_DATE('2014'), '%Y') AS statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amountFROM t_stu_info t WHERE 1 = 1 AND DATE_FORMAT(t.statisDate, '%Y') = '2014'
The format of the MySQL built-in function str_to_date is: str_to_date (string, date format );
In this query SQL, It is str_to_date (string), resulting in an error
3. Solution
Modify query SQL statements
SELECT t.`name`, DATE_FORMAT(STR_TO_DATE('2015','%Y'), '%Y') AS statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amountFROM t_stu_info t WHERE 1 = 1 AND DATE_FORMAT(t.statisDate, '%Y') = '2015' UNIONALL SELECT t.`name`, DATE_FORMAT(STR_TO_DATE('2014','%Y'), '%Y') AS statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amountFROM t_stu_info t WHERE 1 = 1 AND DATE_FORMAT(t.statisDate, '%Y') = '2014'