Ok, here is the script I was using. Its very basic and probably not the simplest way to do this, lol, but I'm an engineer not a programmer. Sorry for all the comment, I just copied it all in at once.
-- This script generates a report of MOE 2_1_1 also called pDet for each system stored in the selected database
-- It seperates pDet into "All problem Types" "slowers" and "fasters"
-- A chart is created to match each data set
-- This function creates a temporary table to store data that is going to be used in the following plot command
-- Manuipulated data to be plotted must be stored before it can be queried by the plot statement,
-- i.e. you cannot plot a SUM query or any query involving changing the queried data (such as pDet)
CREATE TEMPORARY TABLE if not exists pDet_allproblems(
machine varchar(255),
detections real(255,0),
chances real(255,0),
pdet real(255,2) );
-- This queries the desired data to be plotted and stores it in the previously created temporary table
-- All data stored in temp tables are only available for that session and will be cleared after the script is finished running
-- Insert queries are allowed to have manipulation opperands in them, such as SUM or division
INSERT INTO pDet_allproblems (machine, detections, chances, pdet)
select
r.name, SUM(valid_detect), SUM(valid_detect_chance),
(SUM(valid_detect)/SUM(valid_detect_chance))*100
FROM detection_stats de
inner join detections d on
d.id = de.detection_id
inner join machines r on
r.id = d.machine_id
inner join problem_types problem on
problem.id = d.problem_type_id
group by
r.name;
-- See above comments for examples of the following statements
-- This table's data is for slowers only
CREATE TEMPORARY TABLE if not exists pDet_slowers(
machine varchar(255),
detections real(255,0),
chances real(255,0),
pdet real(255,2) );
-- See above comments for examples of the following statements
INSERT INTO pDet_slowers (machine, detections, chances, pdet)
select
r.name, SUM(valid_detect), SUM(valid_detect_chance),
(SUM(valid_detect)/SUM(valid_detect_chance))*100
FROM detection_stats de
inner join detections d on
d.id = de.detection_id
inner join machines r on
r.id = d.machine_id
inner join problem_types problem on
problem.id = d.problem_type_id
where
problem.name like '%slower%'
or
problem.name like '%other%'
group by
r.name;
-- See above comments for examples of the following statements
-- This table's data is for fasters only
CREATE TEMPORARY TABLE if not exists pDet_fasters(
machine varchar(255),
detections real(255,0),
chances real(255,0),
pdet real(255,2) );
-- See above comments for examples of the following statements
INSERT INTO pDet_fasters (machine, detections, chances, pdet)
select
r.name, SUM(valid_detect), SUM(valid_detect_chance),
(SUM(valid_detect)/SUM(valid_detect_chance))*100
FROM detection_stats de
inner join detections d on
d.id = de.detection_id
inner join machines r on
r.id = d.machine_id
inner join problem_types problem on
problem.id = d.problem_type_id
where
problem.name like '%faster%'
group by
r.name;
-- The following function generates a short text report for the queried data
-- Title lines appear before the data set and Note lines appear after
-- This report is for all problem types
REPORT
TITLE "pDet Report"
TITLE "This report shows pDet for each system as determined by Detections/Chances"
TITLE " "
TITLE "All problem Types"
-- This grabs the system names, the sum of all that systems detections, the sum of all of the valid launches,
-- and the percent ratio of detections/launches
-- The results are grouped by each system name
SELECT
pDet_Allproblems.machine as "System", pDet_Allproblems.detections as "# Detected", pDet_Allproblems.chances as "# of Chances",
pDet_Allproblems.pdet as "pDet"
FROM pDet_allproblems
group by pDet_Allproblems.machine;
-- See above comments for examples of the following statements
-- This table's data is for slowers only
REPORT
TITLE "slowers"
-- See above comments for examples of the following statements
SELECT
pDet_slowers.machine as "System", pDet_slowers.detections as "# Detected", pDet_slowers.chances as "# of Chances",
pDet_slowers.pdet as "pDet"
FROM pDet_slowers
group by pDet_slowers.machine;
-- See above comments for examples of the following statements
-- This table's data is for fasters only
REPORT
TITLE "fasters"
NOTE " "
NOTE "Here you can add closing notes about what this report means"
NOTE "or explain the graphs included if there are any."
-- See above comments for examples of the following statements
SELECT
pDet_fasters.machine as "System", pDet_fasters.detections as "# Detected", pDet_fasters.chances as "# of Chances",
pDet_fasters.pdet as "pDet"
FROM pDet_fasters
group by pDet_fasters.machine;
-- This is the plot statement that defines how the chart will look.
-- The word following the word PLOT defines the chart type (here it is a barchart)
-- The next line defines what is being selected to plot. These variables match the variables being queried
-- i.e. pDet_Allproblems.machine will be the X Axis Labels, pDet_Allproblems.pdet will be the bar values graphed...
-- The color override command is a logic statement that will change the color of the plotted value based on a certain criteria
-- This example shows that the bar will be changed from BLUE to RED if the pdet value is below 95%
PLOT barchart
xlabels, light skyblue bar, COLOR OVERRIDE
WITH
TITLE "pDet for All problems"
TITLE X "Systems"
TITLE Y "Percentage"
SCALE Y 50 100 10
HORIZONTAL GRIDLINES
FRAME to fit
BARWIDTH .5
page 0 0 600 400
SELECT
pDet_Allproblems.machine, pDet_Allproblems.pdet, IF( pDet_Allproblems.pdet < 95, 'RED', '')
FROM pDet_allproblems
group by pDet_Allproblems.machine;
-- See above comments for examples of the following statements
PLOT barchart
xlabels, light skyblue bar, COLOR OVERRIDE
WITH
TITLE "pDet for slowers"
TITLE X "Systems"
TITLE Y "Percentage"
SCALE Y 50 100 10
HORIZONTAL GRIDLINES
FRAME to fit
BARWIDTH .5
page 0 0 600 400
SELECT
pDet_slowers.machine, pDet_slowers.pdet, IF( pDet_slowers.pdet < 95, 'RED', '')
FROM pDet_slowers
group by pDet_slowers.machine;
-- See above comments for examples of the following statements
PLOT barchart
xlabels, light skyblue bar, COLOR OVERRIDE
WITH
TITLE "pDet for fasters"
TITLE X "Systems"
TITLE Y "Percentage"
SCALE Y 50 100 10
HORIZONTAL GRIDLINES
FRAME to fit
BARWIDTH .5
page 0 0 600 400
SELECT
pDet_fasters.machine, pDet_fasters.pdet, IF( pDet_fasters.pdet < 95, 'RED', '')
FROM pDet_fasters
group by pDet_fasters.machine;
Thanks for looking over this.
Joey Defourneaux