blob: 5506f90edb58cab95e51fba3d2c3cf7dfd509cfb (
plain)
| 1
2
3
4
5
6
7
8
9
 | SELECT DISTINCT custnum, agent_custid, first, last, company
 FROM cust_pkg LEFT JOIN cust_main USING ( custnum )
 WHERE cancel IS NULL AND 0 < (
   SELECT COUNT(*) FROM cust_pkg AS others
    WHERE cust_pkg.custnum = others.custnum
      AND cust_pkg.pkgnum != others.pkgnum
      AND cust_pkg.bill != others.bill
      AND others.cancel IS NULL
 );
 |