MySQL data problem grounp by OK?

Source: Internet
Author: User
Tables table, Fields
I want to get the sum of d_consutotal, but the condition is to From_unixtime (d_inputdate, '%y-%m ') = ' 2015-02 ' and d_adaccount= ' 1 ', and conditionally, the same d_ Consutotal only take one (the result is 3055.52+1111.11 ...), now all of these d_inputdate are "2015-02" after the conversion.
How do I write this statement?


Reply to discussion (solution)

Sum function for sum
Sum of d_consutotal, sum of writing (D_consutotal)
The same d_consutotal only takes one, then writes sum (DISTINCT d_consutotal)

Since you have From_unixtime (d_inputdate, '%y-%m ') = ' 2015-02 ' and d_adaccount= ' 1 ' constraints, you will naturally only get data results for February 2015

Sum function for sum
Sum of d_consutotal, sum of writing (D_consutotal)
The same d_consutotal only takes one, then writes sum (DISTINCT d_consutotal)

Since you have From_unixtime (d_inputdate, '%y-%m ') = ' 2015-02 ' and d_adaccount= ' 1 ' constraints, you will naturally only get data results for February 2015


Zu Ning brother really knowledgeable ah, has been done.
  • 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.