Гость
24 Фев 2014 07:17

Hello, I am interested in creating a running total for customer profiles. I've created a Type called Customer Log which contains several fields, including a number field called Amount. How can I perform calculations to the Amount field for these records? For example, I would like to calculate the total number of records (of this Type) and divide by the sum of the Amount field.

Thanks! :D

Последние изменения: 02 Март 2014


Sergey
Total posts: 13,748
24 Фев 2014 07:55

You will have to run SQL query.

If you understand what is #__js_res_record_values table, than you can do anything.

You can get total by

$sql = "SELECT SUM(field_value) FROM #__js_res_record_values WHERE field_id = 10 AND user_id = {$item->user_id}";

$db = Jfactory::getDBO();

$db->setQuery($sql);

$result = $db->loadResult();

Гость
24 Фев 2014 08:19

Oh okay you're using PHP. So in other words, I should create a special template and insert this coding. I believe I got it! Thanks again, Serg!

Работает на Cobalt