I want to be able to count how many times a 0 or a 1 appears in the TestResults_Bad_num. I want it to look through all the rows that have imported and return a variable hopefully. Or something that I can bind to a custom property so I can display it in a label.
This is the query I have so far. For context WorkOrder is a parameter I have that is linked to a custom properly. In a perfect world TestResults_Bad_num wouldnt be displayed on the table either.
SELECT ActiveWorkOrder_num,Record_ID,TestResults_Bad_num
FROM LeakTest_Part_Tracking
WHERE ActiveWorkOrder_num = :WorkOrder
SELECT
ActiveWorkOrder_num,
Record_ID,
case
when TestResults_Bad_num = 0 then 'Passed'
else 'Failed'
end as Result,
count(*) as total
FROM
LeakTest_Part_Tracking
WHERE
ActiveWorkOrder_num = :WorkOrder
GROUP BY
TestResults_Bad_num
When I test that query I get the following error message
com.microsoft.sqlserver.jdbc.SQLServerException: Column 'LeakTest_Part_Tracking.ActiveWorkOrder_num' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
SELECT [TestResults_Bad_Num] as PassFail,COUNT([ActiveWorkOrder_num]) as Ttl,ActiveWorkOrder_num FROM [LeakTest_Part_Tracking] WHERE ActiveWorkOrder_num = :WorkOrder GROUP BY [TestResults_Bad_Num],[ActiveWorkOrder_num]
There are 40 Passes so I’m assuming the Ttl is how many passed and the PassFail is how many failed.
Would it maybe be easier to have a separate query that handles this totaling and another one that handles what is going to be displayed?
You will have two records if you have failures and passes with that query.
To combine to one record just do something like
SELECT
COUNT(CASE WHEN TestResults_Bad_num = 0 THEN 1 END) as Passed,
COUNT(CASE WHEN TestResults_Bad_num = 1 THEN 1 END) as Failed
FROM [LeakTest_Part_Tracking]
WHERE ActiveWorkOrder_num = :WorkOrder
Note: This is okay for testing purposes, but you really don't want to do this in production.
Ignition and SQL databases have similar IO patterns and tend to try to "fight" for the same kinds of resources (CPU time, memory) when they're installed in the same OS instance. It's generally recommended to keep them isolated from each other in separate VMs [1]/containers/physical hardware.
Um, dis-similar. And it is the CPU utilization that I've noted as the biggest problem: Ignition needs some idle time to keep latency down, where a DB will consume all available CPU. (RAM is a problem, too, if you don't tell Ignition to grab what it needs up front.)