drop table if exists t;
create table t (ID varchar(3), Var1 int, Dt datetime);
insert into t values
('A-1' , 5 , '2017-04-01 18:45:05'),
('A-2' , 8 , '2017-04-01 18:45:05'),
('A-3' , 5 , '2017-04-01 18:45:05'),
('A-3' , 5 , '2017-04-02 18:45:05'),
('A-4' , 8 , '2017-04-02 18:45:05'),
('A-6' , 8 , '2017-04-03 18:45:05');
select dt,count(id) NofID,
sum(case when var1 = 8 then 1 else 0 end) nofeights,
(sum(case when var1 = 8 then 1 else 0 end) / count(id)) * 100 eights
from t
group by dt;
+---------------------+-------+-----------+----------+
| dt | NofID | nofeights | eights |
+---------------------+-------+-----------+----------+
| 2017-04-01 18:45:05 | 3 | 1 | 33.3333 |
| 2017-04-02 18:45:05 | 2 | 1 | 50.0000 |
| 2017-04-03 18:45:05 | 1 | 1 | 100.0000 |
+---------------------+-------+-----------+----------+
3 rows in set (0.00 sec)