Results 1 to 2 of 2

Thread: query?

  1. #1

    Thread Starter
    Hyperactive Member Dorothy's Avatar
    Join Date
    Feb 2001
    Posts
    310

    Question query?

    table name: sb
    studid studname amount
    ----------------------------------
    1 a 1000
    2 b 2000
    3 c 1000
    4 d 3000

    table name: bill
    studid amt_paid amt_due
    ----------------------------------
    1 300 700
    1 300 400
    2 500 1500
    2 500 1000

    bill.studid is a foreign key of sb.studid
    the amount paid is deducted from amount .
    I need an output of this format

    studid studname amount amt_paid amt_due
    ----------------------------------------------------------------------
    1 a 1000 600 400
    2 b 2000 1000 1000
    3 c 1000 0 1000
    4 d 3000 0 3000

    help me in constructing the query?

  2. #2
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    Try this:

    Code:
    select sb.*, bill.* from sb, bill where sb.studid = bill.studid

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width