Posts

Command sql query

ลูกค้าที่ Create ตั้งแต่ Jan 1 และมีการสั่งซื้อสินค้าและจ่ายเงินแล้ว SELECT inv.id,cus.create_dt,cus.fullname,dm.domain,pdn.name,invp.unit,invp.price_per_unit,invp.price FROM `tb160_invoice_product` invp LEFT JOIN `tb11_customer` cus ON cus.no = invp.customer_no LEFT JOIN `tb164_product_name` pdn ON invp.product_name_no = pdn.no LEFT JOIN `tb159_invoice` inv on invp.invoice_no = inv.no LEFT JOIN `tb172_invoice_product_package` dm on invp.invoice_no = dm.invoice_no WHERE cus.create_dt > '2023-01-01' and inv.invoice_type = 'new' and inv.paid_status = 2 and (pdn.`type_no` = 1 AND (pdn.group_name in ('Go Cloud (Fixed User)','Go Cloud (Private Server)','Go Cloud (Unlimited User)')) or (pdn.name in ('Hybrid Email Go Cloud 200 GB (Fixed Disk)','Hybrid Email Go Cloud 3 GB (Fixed User)','Hybrid Email Go Cloud 5 GB (Fixed User)','Hybrid Email Go Cloud 5 GB (Fixed User)','Hybrid Email Go Cloud 7 GB (Fixed User)'