MySQL learning _ Calculate user payment method accounted for _20161104

Source: Internet
Author: User

Calculate User Payment Method percentage

SELECTB.*#根据城市ID Chronological order from (    SELECTA.*     from(#纵向合并SELECTB1.id,a1. City, A1. Collection method, Date_format (A1. Confirmation Time, "%Y%M ") asYearsSUM(A1. Amount) asCollection Method Amount from' A029_collectionment ' asA1 Left JOIN' A000_city ' asB1 onA1. City=B1. CityWHEREA1. Confirmation Time>" .- on- on" andA1. Confirmation Time<current_date  andA1. Collection method="Cash"GROUP  byA1. City, Date_format (A1. Confirmation Time, "%Y%m "))  asaUNION  All    (        SELECTD1.id,c1. City, C1. Collection method, Date_format (c1. Payment Time, "%Y%M ") asYearsSUM(C1. Amount) asCollection Method Amount from' A031_order_paypal ' asC1 Left JOIN' A000_city ' asD1 onD1. City=C1. CityWHEREC1. Payment Time>" .- on- on" andC1. Payment Time<current_date        GROUP  byC1. City, C1. Collection method, Date_format (c1. Payment Time, "%Y%M ")))  asbORDER  byB.id,b. Month

MySQL learning _ Calculate user payment method accounted for _20161104

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.