For example, in a select
in the database, 5 records will be returned:
SELECT * FROM esc_usuarios
WHERE usu_indicador_codigo = '" . $_SESSION['codigo'] . "'
AND usu_situacao = 'ativo'"
Then I want to assign a value for each record, for example 10. Now I want to give a echo
in the sum of the value of all those records, that is, 5 (select records) x 10 (value assigned for each record) , then returning the number 50. How can I do this?
Update 0: New query
SELECT usu_nome, (
(SELECT (count(usu_codigo)*10) FROM esc_usuarios WHERE usu_indicador_codigo = a.usu_codigo AND usu_situacao = 'ativo')
+
(SELECT (count(usu_codigo)*5) FROM esc_usuarios WHERE usu_indicador_codigo in (
(SELECT usu_codigo FROM esc_usuarios WHERE usu_indicador_codigo = a.usu_codigo AND usu_situacao = 'ativo')
))
) usu_porcentagem
FROM esc_usuarios a
WHERE usu_codigo = 1