Operating department to give users coupons, if you want to monitor the use of coupons coupon usage rate is a good indicator of the effect
The following SQL is the daily use of coupons issued for a particular user on a given day after the release date
SELECTE. City, E. User id,i. Contact number, H. Order date, H. Order id,h, H. Order Amount, E. Coupon id,e. Coupon name, Case whenH. Preferential amount is NULL Then"Coupon Not used"ELSE"Use coupon"END aswhether the issued restaurant uses coupons, E. Coupon stalls, H. Offer from ( SELECTA1. City, A1. User id,date (A1. Release date) asRelease date, A1. Coupon id,a1. Coupon name, Right(A1. Coupon name, char_length (A1. Coupon name)-Char_length ( Left(A1. Coupon name, INSTR (A1. Coupon name, "" ")-1))) asCoupon Stalls from' A015_customer_coupon ' asA1WHEREA1. City=Hangzhou andA1. Date of issue>=" .-Ten- at" andA1. Date of issue<" .-Ten- -" andA1. Coupon ID>=939 andA1. Coupon ID<=951 GROUP byA1. User ID) ase Left JOIN ( SELECTF.*, G. Coupon id,g. Coupon Name, G. Offer from ( SELECTF1. City, F1. User id,date (Order date) asOrder date, F1. Order ID,F1. Sales clerk,SUMAmount asOrder Amount from' A003_order ' asF1WHEREF1. Amount>0 andF1. Order Date>=" .-Ten- -" andF1. Order Date<" .- One- -" GROUP byF1. Order ID) asF Left JOIN ( SELECTB1. City, Date (B1. Use time) asDate of use, B1. User id,b1. Order number, B1. Coupon id,b1. Coupon name,SUM(B1. Coupon amount) asDiscount Amount from' A016_order_customercoupon_xref ' asB1WHEREB1. City=Hangzhou andB1. Use time>=" .-Ten- -" andB1. Use time<" .- One- -" andB1. Coupon ID>=939 andB1. Coupon ID<=951 GROUP byB1. Order number) asG onG. Order number=F. Order ID) asH onE. User ID=H. User ID Left JOIN' A001_resterant ' asI onI. User ID=e. User IDWHEREE. Coupon Stalls<>"No coupon"ORDER byFIELD (whether the issuing restaurant uses coupons, "coupon", "Coupon Not used")
MySQL business-issued coupons for user usage _20161028