User Profile

Collapse

Profile Sidebar

Collapse
tracerstevens
tracerstevens
Last Activity: Dec 21 '11, 07:51 PM
Joined: Dec 14 '11
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • tracerstevens
    replied to Comparing SUM of two tables
    Rabbit,
    As I was putting together some sample data for you I figured out that the query above does work but not when I applied it to my real data.

    I found out that if there are no ROGs, it returns NULL instead of 0, so I had to use:

    Code:
    SELECT COALESCE(SUM(quantity),0) FROM rog_bom WHERE po_ID=po.ID
    Thanks for your help, you got me to the solution
    See more | Go to post

    Leave a comment:


  • tracerstevens
    replied to Comparing SUM of two tables
    Code:
    SELECT
     *,
     po.ID AS po_ID
    FROM
     purchase_order po
    WHERE
     (SELECT SUM(quantity) FROM rog_bom WHERE rog_bom.po_ID=po.ID) < (SELECT SUM(quantity) AS po_bom_total FROM purchase_order_bom po_bom WHERE po_bom.po_ID=po.ID)
    Is it clear what I'm trying to produce, or is that confusing as well?

    Thank you,
    Andy
    See more | Go to post

    Leave a comment:


  • tracerstevens
    replied to Comparing SUM of two tables
    Code:
    SELECT
     *,
     po.ID AS po_ID
    FROM
     purchase_order po
    WHERE
     (SELECT SUM(quantity) FROM rog_bom WHERE rog_bom.po_ID=po.ID) < (SELECT SUM(quantity) AS po_bom_total FROM purchase_order_bom po_bom WHERE po_bom.po_ID=po.ID)
    Is it clear what I'm trying to produce, or is that confusing as well?

    Thank you,
    Andy
    See more | Go to post

    Leave a comment:


  • tracerstevens
    replied to Comparing SUM of two tables
    Hi Rabbit,

    Good eye, I've changed it around so that ROG total is first. So it checks if ROG_bom < PO_bom. But it still only shows one PO, which actually has the ROG_bom total equeal to PO_bom, so it doesn't make sense.

    There should be about 30 PO's that have less items received than ordered.

    Am I writing the query correctly? Or am I totally off base?

    Thanks!
    Andy
    See more | Go to post
    Last edited by tracerstevens; Dec 19 '11, 09:40 PM. Reason: More Info

    Leave a comment:


  • tracerstevens
    started a topic Comparing SUM of two tables

    Comparing SUM of two tables

    Hi Everyone,
    This one is driving me crazy.

    I have three tables: purchase_order, purchase_order_ bom, and rog_bom.

    The table purchase_order_ bom is a list of parts ordered for the purchase order. The table rog_bom is a list of parts received for the purchase order (ROG stands for receipt of goods).

    I want to run a query that looks through table purchase_order but only show the purchase orders that...
    See more | Go to post
No activity results to display
Show More
Working...