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