Results 1 to 2 of 2

Thread: some complex joining access sql query

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2003
    Posts
    237

    some complex joining access sql query

    here my database tables

    CASH
    Id ProductId Qty
    INVOICE
    Id ProductId Qty
    PURCHASE RETURN
    Id ProductId Qty

    STOCKIN
    Id ProductId Qty
    CREDITNOTE
    Id ProductId Qty


    so my stock balance should be (STOCKIN.Qty + CREDITNOTE.Qty) - (CASH.Qty + INVOICE.Qty + PURCHASE RETURN.Qty)

    how to do this in access sql?

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    You may try executing sql statement that looks similar to the following:

    SELECT
    c.ProductId,
    SUM(s.Qty + cn.Qty) - SUM(c.Qty + i.Qty + pr.Qty) 'Stock_Balance'
    FROM CASH c, INVOICE i, PURCHASE_RETURN pr,
    STOCKIN s, CREDITNOTE cn
    WHERE i.ProductId = c.ProductId
    AND pr.ProductId = c.ProductId
    AND s.ProductId = c.ProductId
    AND cn.ProductId = c.ProductId

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