Error code: 1582 Incorrect parameter count in the call to native function & #39; str_to_date & #39;, parameter

Source: Internet
Author: User

Error code: 1582 Incorrect parameter count in the call to native function 'str _ to_date ', parameter
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'

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.