--查询商品对应的所有票价都是售完状态的商品 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:售完 )
-------------------
--订单状态为未审核,订单类型为选座或抢座,订单支付状态为部分支付,且支付详情中不存在电子钱支付方式之外的已支付的记录。 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) --订单类型为选座或抢座,状态为未审核,支付状态为部分支付, 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 ); --所有支付详情没有这种情况:支付状态为已支付,支付方式不是电子钱包