oracle subquery correlation

--All fares corresponding to the query products are sold out select tp.productid from t_product tp where not exists( select 1 from t_productplay tpp where tpp.productid = tp.productid and tpp.starus != 2 -- 2 : sold out )

-------------------
--The order status is unreviewed, the order type is seat selection or seat grabbing, the order payment status is partial payment, and there is no payment record other than electronic money payment method in the payment details.
select t.ordersid, t.customersid,tm.paymentid,t.createtime,t.starus,tm.paystatus,tm.discount,  
		 
		 (select nvl(sum(tpd.actual_fee),0) from t_payment_detail tpd where tpd.order_id=t.ordersid and tpd.discountdetailid=66985007 and tpd.payment_status=1
     ) as yckprice  
		 
from t_orders t, t_payment tm
where t.starus = 1 and tm.paystatus = 1 and (t.type = 1 or t.type = 20)  and tm.ordersid = t.ordersid and trunc(t.createtime) <= trunc(sysdate)  
      --The order type is seat selection or grab seat, the status is unreviewed, and the payment status is partial payment,
		  and not exists(
                     select 1 from t_payment_detail tpd
                     where tpd.order_id=t.ordersid and tpd.discountdetailid not in(66985007) and tpd.payment_status=1
                     );
                    -- This is not the case for all payment details: the payment status is paid, and the payment method is not an e-wallet






Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326769013&siteId=291194637
Recommended