/*This SQL script uses the Demo database.

  This sample illustrates complex sql statements linking
 4 tables together to come up with a "Sales" information
  table. This is the same as the 'Sales.sql' except this
  one only returns results where the customer has
  not made a payment on the order yet.
*/

SELECT *
FROM
 customer a,
 orders b,
 items c,
 parts d
WHERE
  (a.custno = b.custno) AND 
  (b.orderno = c.orderno) AND 
  (c.partno = d.partno) AND
  (b.amountpaid = 0)
ORDER BY
  a.company,
  orderno
