943,703 Members | Top Members by Rank

Ad:
  • ColdFusion Discussion Thread
  • Marked Solved
  • Views: 912
  • ColdFusion RSS
Jan 7th, 2009
0

Database return records issue

Expand Post »
Hi all,
I have a bit of an issue with an application that i am currently developing.
The application logs passed and failure information for a production line.
Each production lineis broken down into operations, each operation has a task group and then each task group has a bunch of tasks.

The failure rate of each task is logged so the following would happen:

Fit solenoid Fit Cover Fit Label
1 3 6

Also for each operation the pass rate is logged.
So the above tasks would come under Operation1.

Operation1 pass rate is 200
So to sum up Operation1 has 200 passed operations and a toal of 10 failures.
I am currently storing the Task failures in one table and the Operation passes in another table.

What i need to do is pull out all of the Task failures for each operation and sum up the values, this i can output without any issues.
This is where i get stuck: i also need to pull out the Operation passes per operation and sum them up in the same query.
My code returns incorrect sum values for the Pass values.
The data is loaded on a daily basis so Operation1 may have 200 passes today and then 15 the next.

Here is the code that i have right now:
ColdFusion Syntax (Toggle Plain Text)
  1. <cfquery datasource="UKCHAPP145" name="Q2">
  2. SELECT
  3. SUM(TBL_PASSED.PASSED_QTY) AS TotalPassedQty,
  4. SUM(TBL_FTBR_DATA.FTBR_FAILED_QTY) AS TotalFailedQty,
  5. TBL_FTBR_DATA.FTBR_OPERATION_UUID,
  6. TBL_PASSED.OPERATION_UUID,
  7. TBL_OPERATION.OPERATION_NAME,
  8. TBL_OPERATION.OPERATION_SORT_ORDER
  9. FROM
  10. UKCHAPP145.TBL_FTBR_DATA,
  11. UKCHAPP145.TBL_OPERATION,
  12. UKCHAPP145.TBL_PASSED
  13. WHERE
  14. TBL_FTBR_DATA.FTBR_OPERATION_UUID = TBL_OPERATION.OPERATION_UUID
  15. AND
  16. TBL_FTBR_DATA.FTBR_OPERATION_UUID = TBL_PASSED.OPERATION_UUID
  17. GROUP BY
  18. TBL_FTBR_DATA.FTBR_OPERATION_UUID,
  19. TBL_OPERATION.OPERATION_NAME,
  20. TBL_OPERATION.OPERATION_SORT_ORDER,
  21. TBL_PASSED.OPERATION_UUID
  22. ORDER BY
  23. TBL_OPERATION.OPERATION_SORT_ORDER
  24. ASC
  25. </cfquery>

The above code outputs the following:
Op Name: FV OP1 - Failed Qty:0 Passed Qty: 5550
Op Name: FV OP 2 - Failed Qty:40 Passed Qty: 415
Op Name: COVER - Failed Qty:0 Passed Qty; 175

The passed Qty's are incorrect.
They should be :
Op Name: FV OP1 - Failed Qty:0 Passed Qty: 370
Op Name: FV OP 2 - Failed Qty:40 Passed Qty: 83
Op Name: COVER - Failed Qty:0 Passed Qty: 25


I am struggling to get the sql correct, can anyone help me out?

Many thanks
JM
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
jedimatt is offline Offline
20 posts
since Jan 2009
Jan 7th, 2009
0

Re: Database return records issue

I managed to get this to work by creating two views.
One for the failed qty table and one for the passed qty table.
Each view summed the failed and passed qtys and i then joined both tables using the op id fields, works just fine.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
jedimatt is offline Offline
20 posts
since Jan 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ColdFusion Forum Timeline: spam filtering
Next Thread in ColdFusion Forum Timeline: Date and Time





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC