| | |
Database return records issue
Please support our ColdFusion advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jan 2009
Posts: 20
Reputation:
Solved Threads: 1
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:
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
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)
<cfquery datasource="UKCHAPP145" name="Q2"> SELECT SUM(TBL_PASSED.PASSED_QTY) AS TotalPassedQty, SUM(TBL_FTBR_DATA.FTBR_FAILED_QTY) AS TotalFailedQty, TBL_FTBR_DATA.FTBR_OPERATION_UUID, TBL_PASSED.OPERATION_UUID, TBL_OPERATION.OPERATION_NAME, TBL_OPERATION.OPERATION_SORT_ORDER FROM UKCHAPP145.TBL_FTBR_DATA, UKCHAPP145.TBL_OPERATION, UKCHAPP145.TBL_PASSED WHERE TBL_FTBR_DATA.FTBR_OPERATION_UUID = TBL_OPERATION.OPERATION_UUID AND TBL_FTBR_DATA.FTBR_OPERATION_UUID = TBL_PASSED.OPERATION_UUID GROUP BY TBL_FTBR_DATA.FTBR_OPERATION_UUID, TBL_OPERATION.OPERATION_NAME, TBL_OPERATION.OPERATION_SORT_ORDER, TBL_PASSED.OPERATION_UUID ORDER BY TBL_OPERATION.OPERATION_SORT_ORDER ASC </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
- sql query problem with MS Access and C# (C#)
- How to configure GD (PHP)
- JSP database connectivity according to Model View Controller (MVC) Model 2 (JSP)
- php.ini confusion (PHP)
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
- memory management in wndows 2000 (Windows NT / 2000 / XP)
Other Threads in the ColdFusion Forum
- Previous Thread: spam filtering
- Next Thread: Date and Time
| Thread Tools | Search this Thread |





