Database return records issue

Thread Solved

Join Date: Jan 2009
Posts: 20
Reputation: jedimatt is an unknown quantity at this point 
Solved Threads: 1
jedimatt jedimatt is offline Offline
Newbie Poster

Database return records issue

 
0
  #1
Jan 7th, 2009
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:
  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
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 20
Reputation: jedimatt is an unknown quantity at this point 
Solved Threads: 1
jedimatt jedimatt is offline Offline
Newbie Poster

Re: Database return records issue

 
0
  #2
Jan 7th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 783 | Replies: 1
Thread Tools Search this Thread



Tag cloud for ColdFusion
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC