From surenkid, 6 Months ago, written in MySQL.
Embed
  1. SELECT a.pid `种子ID`,a.pname `种子姓名`,a.id `一级ID`,b.vipname `一级姓名`,b.vipmobile `手机号`,b.vipaddress `收货地址`,a.total_sub `总订单数` FROM
  2. (
  3.         -- 此处是不包含收货地址的查询
  4.         SELECT v.pid,vv.`name` pname,v.id,v.`name`,v.mobile,(v.groupbuy_sub+1) total_sub
  5.         FROM wfx_vip v
  6.         LEFT JOIN wfx_vip vv ON v.pid = vv.id
  7.         WHERE v.pid in (SELECT id FROM `wfx_vip` WHERE plv = 1)
  8.         AND v.id in (SELECT DISTINCT vipid FROM wfx_shop_order WHERE ispay = 1 AND format(totalprice,2) = 29.9)
  9.         ORDER BY v.pid
  10. ) a
  11. LEFT JOIN (SELECT DISTINCT vipid,vipname,vipmobile,vipaddress FROM wfx_shop_order WHERE ispay = 1 AND format(totalprice,2) = 29.9) b
  12. ON a.id = b.vipid