add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE test (Part CHAR(8), Runs INT, Duration INT, `Date` DATE);
INSERT INTO test VALUES
('random_1', NULL , 20 , '2020-01-01'),
('random_2', NULL , 1 , '2020-01-01'),
('random_3', NULL , 4 , '2020-01-01'),
('tot_rand', 40 , NULL , '2020-01-01'),
('random_1', NULL , 60 , '2020-01-02'),
('random_2', NULL , 12 , '2020-01-02'),
('random_3', NULL , 3 , '2020-01-02'),
('tot_rand', 100 , NULL , '2020-01-02'),
('random_1', NULL , 9 , '2020-01-10'),
('random_2', NULL , 4 , '2020-01-10'),
('tot_rand', 30 , NULL , '2020-01-10');
SELECT * FROM test;
Part Runs Duration Date
random_1 null 20 2020-01-01
random_2 null 1 2020-01-01
random_3 null 4 2020-01-01
tot_rand 40 null 2020-01-01
random_1 null 60 2020-01-02
random_2 null 12 2020-01-02
random_3 null 3 2020-01-02
tot_rand 100 null 2020-01-02
random_1 null 9 2020-01-10
random_2 null 4 2020-01-10
tot_rand 30 null 2020-01-10
SELECT t1.Part, t2.Runs, t1.Duration, `Date`, 1 - t1.Duration / t2.Runs `All`
FROM test t1
JOIN test t2 USING (`Date`)
WHERE t2.Part = 'tot_rand'
Part Runs Duration Date All
random_1 40 20 2020-01-01 0.5000
random_2 40 1 2020-01-01 0.9750
random_3 40 4 2020-01-01 0.9000
tot_rand 40 null 2020-01-01 null
random_1 100 60 2020-01-02 0.4000
random_2 100 12 2020-01-02 0.8800
random_3 100 3 2020-01-02 0.9700
tot_rand 100 null 2020-01-02 null
random_1 30 9 2020-01-10 0.7000
random_2 30 4 2020-01-10 0.8667
tot_rand 30 null 2020-01-10 null