Mysql data problems grounpby rows not good?

Source: Internet
Author: User
Mysql data problems grounpby rows not good? Table, field
I want to get the sum of d_consutotal, but the condition is FROM_UNIXTIME (d_inputdate, '% Y-% M') = '2017-02' AND d_adaccount = '1 ', and according to the condition, only one of the same d_consutotal is obtained (the expected result is 3055.52 + 1111. 11 .........), now all the d_inputdate conversions are "2015-02.
How can I write this statement?


Reply to discussion (solution)

Sum function
Sum d_consutotal and write sum (d_consutotal)
Write sum (DISTINCT d_consutotal) for the same d_consutotal)

Since you have FROM_UNIXTIME (d_inputdate, '% Y-% M') = '2017-02' AND d_adaccount = '1' constraints, you will naturally only get the data results of March 2015.

Sum function
Sum d_consutotal and write sum (d_consutotal)
Write sum (DISTINCT d_consutotal) for the same d_consutotal)

Since you have FROM_UNIXTIME (d_inputdate, '% Y-% M') = '2017-02' AND d_adaccount = '1' constraints, you will naturally only get the data results of March 2015.


Brother zounin is really familiar with Bo Wen, and he has done it.

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.