Given an array of text value - quantity:
[('21', 1), ('25', 1), ('28', 1), ('31', 1), ('Данных нет', 14)] It is necessary to calculate the percentage of each value in general. The result should be:
['21', '1 / (1 + 1 + 1 + 1 + 14)'; '25', '1 / (1 + 1 + 1 + 1 + 14)'; '28', '1 / (1 + 1 + 1 + 1 + 14)'; '31', '1 / (1 + 1 + 1 + 1 + 14)'; 'Данных нет', '14 / (1 + 1 + 1 + 1 + 14)'] where 1/18 - это расчет процентов .
There is such a view on SQL:
CREATE ALGORITHM = UNDEFINED DEFINER = `user`@`%` SQL SECURITY DEFINER VIEW `users_by_age` AS SELECT `list_of_users`.`age` AS `age`, COUNT(0) AS `number` FROM `list_of_users` GROUP BY `list_of_users`.`age` You can add 1 more column, but how is the question.