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 tablename (`day` INTEGER, `person` VARCHAR(4), `amount` INTEGER);

INSERT INTO tablename (`day`, `person`, `amount`) VALUES
('1', 'John', '4'),
('1', 'Sam', '6'),
('2', 'John', '3'),
('3', 'John', '3'),
('3', 'Sam', '5'),
('4', 'John', '3');
Records: 6  Duplicates: 0  Warnings: 0
SELECT person,
100 * AVG(amount > 3) percent
FROM tablename
GROUP BY person;
person percent
John 25.0000
Sam 100.0000
SELECT person,
100 * AVG(amount > 5) percent
FROM tablename
GROUP BY person;
person percent
John 0.0000
Sam 50.0000