USE [IMTsimulations]
GO
SELECT SUM(CASE WHEN Xa BETWEEN 90 and 130 THEN 1 ELSE 0 end)/SUM(1) AS Xa_PIR2
FROM [dbo].[Simulations]
WHERE [dbo].[Simulations].[ExperimentID] IN (
SELECT [ExperimentID] FROM [dbo].[Parameters] WHERE [SensorError] = 1 AND [ExogDEXCurve] <> 4 AND [ControlRange] = 2
)
/*GROUP BY Xa_PIR2 WHERE Xa_PIR2 < .6, Xa_PIR2 BETWEEN .6 AND .8, Xa_PIR2 BETWEEN .8 AND 1
My attempt at the group, obviously doesn't work. */
GO
I know I could do a SELECT FROM PERCENT_IN_RANGE_TABLE, kind of like they did here, but I've got no such table. I want to do this on the fly, as I'm only going to do this specific analysis once.
Ideally, I would have a percentage of experiments that fall into each "Time In Range" group. I want to know what percentage of Experiments (uniquely identified by ExperimentID) have less than 60% time in range, what percent have 60-80% time in range, and what percent have 80-100% time in range.